Skip to main content

gtk/auto/
lock_button.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
5use crate::{
6    Actionable, Align, Bin, Buildable, Button, Container, PositionType, ReliefStyle, ResizeMode,
7    Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17    /// GtkLockButton is a widget that can be used in control panels or
18    /// preference dialogs to allow users to obtain and revoke authorizations
19    /// needed to operate the controls. The required authorization is represented
20    /// by a [`gio::Permission`][crate::gio::Permission] object. Concrete implementations of [`gio::Permission`][crate::gio::Permission] may use
21    /// PolicyKit or some other authorization framework. To obtain a PolicyKit-based
22    /// [`gio::Permission`][crate::gio::Permission], use `polkit_permission_new()`.
23    ///
24    /// If the user is not currently allowed to perform the action, but can obtain
25    /// the permission, the widget looks like this:
26    ///
27    /// ![](lockbutton-locked.png)
28    ///
29    /// and the user can click the button to request the permission. Depending
30    /// on the platform, this may pop up an authentication dialog or ask the user
31    /// to authenticate in some other way. Once the user has obtained the permission,
32    /// the widget changes to this:
33    ///
34    /// ![](lockbutton-unlocked.png)
35    ///
36    /// and the permission can be dropped again by clicking the button. If the user
37    /// is not able to obtain the permission at all, the widget looks like this:
38    ///
39    /// ![](lockbutton-sorry.png)
40    ///
41    /// If the user has the permission and cannot drop it, the button is hidden.
42    ///
43    /// The text (and tooltips) that are shown in the various cases can be adjusted
44    /// with the [`text-lock`][struct@crate::LockButton#text-lock], [`text-unlock`][struct@crate::LockButton#text-unlock],
45    /// [`tooltip-lock`][struct@crate::LockButton#tooltip-lock], [`tooltip-unlock`][struct@crate::LockButton#tooltip-unlock] and
46    /// [`tooltip-not-authorized`][struct@crate::LockButton#tooltip-not-authorized] properties.
47    ///
48    /// ## Properties
49    ///
50    ///
51    /// #### `permission`
52    ///  Readable | Writeable
53    ///
54    ///
55    /// #### `text-lock`
56    ///  Readable | Writeable | Construct
57    ///
58    ///
59    /// #### `text-unlock`
60    ///  Readable | Writeable | Construct
61    ///
62    ///
63    /// #### `tooltip-lock`
64    ///  Readable | Writeable | Construct
65    ///
66    ///
67    /// #### `tooltip-not-authorized`
68    ///  Readable | Writeable | Construct
69    ///
70    ///
71    /// #### `tooltip-unlock`
72    ///  Readable | Writeable | Construct
73    /// <details><summary><h4>Button</h4></summary>
74    ///
75    ///
76    /// #### `always-show-image`
77    ///  If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
78    /// setting and always show the image, if available.
79    ///
80    /// Use this property if the button would be useless or hard to use
81    /// without the image.
82    ///
83    /// Readable | Writeable | Construct
84    ///
85    ///
86    /// #### `image`
87    ///  The child widget to appear next to the button text.
88    ///
89    /// Readable | Writeable
90    ///
91    ///
92    /// #### `image-position`
93    ///  The position of the image relative to the text inside the button.
94    ///
95    /// Readable | Writeable
96    ///
97    ///
98    /// #### `label`
99    ///  Readable | Writeable | Construct
100    ///
101    ///
102    /// #### `relief`
103    ///  Readable | Writeable
104    ///
105    ///
106    /// #### `use-stock`
107    ///  Readable | Writeable | Construct
108    ///
109    ///
110    /// #### `use-underline`
111    ///  Readable | Writeable | Construct
112    ///
113    ///
114    /// #### `xalign`
115    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
116    /// can be used to control its horizontal alignment. 0.0 is left aligned,
117    /// 1.0 is right aligned.
118    ///
119    /// Readable | Writeable
120    ///
121    ///
122    /// #### `yalign`
123    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
124    /// can be used to control its vertical alignment. 0.0 is top aligned,
125    /// 1.0 is bottom aligned.
126    ///
127    /// Readable | Writeable
128    /// </details>
129    /// <details><summary><h4>Container</h4></summary>
130    ///
131    ///
132    /// #### `border-width`
133    ///  Readable | Writeable
134    ///
135    ///
136    /// #### `child`
137    ///  Writeable
138    ///
139    ///
140    /// #### `resize-mode`
141    ///  Readable | Writeable
142    /// </details>
143    /// <details><summary><h4>Widget</h4></summary>
144    ///
145    ///
146    /// #### `app-paintable`
147    ///  Readable | Writeable
148    ///
149    ///
150    /// #### `can-default`
151    ///  Readable | Writeable
152    ///
153    ///
154    /// #### `can-focus`
155    ///  Readable | Writeable
156    ///
157    ///
158    /// #### `composite-child`
159    ///  Readable
160    ///
161    ///
162    /// #### `double-buffered`
163    ///  Whether the widget is double buffered.
164    ///
165    /// Readable | Writeable
166    ///
167    ///
168    /// #### `events`
169    ///  Readable | Writeable
170    ///
171    ///
172    /// #### `expand`
173    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `focus-on-click`
179    ///  Whether the widget should grab focus when it is clicked with the mouse.
180    ///
181    /// This property is only relevant for widgets that can take focus.
182    ///
183    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
184    /// GtkComboBox) implemented this property individually.
185    ///
186    /// Readable | Writeable
187    ///
188    ///
189    /// #### `halign`
190    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
191    ///
192    /// Readable | Writeable
193    ///
194    ///
195    /// #### `has-default`
196    ///  Readable | Writeable
197    ///
198    ///
199    /// #### `has-focus`
200    ///  Readable | Writeable
201    ///
202    ///
203    /// #### `has-tooltip`
204    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
205    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
206    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
207    /// whether it will provide a tooltip or not.
208    ///
209    /// Note that setting this property to [`true`] for the first time will change
210    /// the event masks of the GdkWindows of this widget to include leave-notify
211    /// and motion-notify events. This cannot and will not be undone when the
212    /// property is set to [`false`] again.
213    ///
214    /// Readable | Writeable
215    ///
216    ///
217    /// #### `height-request`
218    ///  Readable | Writeable
219    ///
220    ///
221    /// #### `hexpand`
222    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
223    ///
224    /// Readable | Writeable
225    ///
226    ///
227    /// #### `hexpand-set`
228    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
229    ///
230    /// Readable | Writeable
231    ///
232    ///
233    /// #### `is-focus`
234    ///  Readable | Writeable
235    ///
236    ///
237    /// #### `margin`
238    ///  Sets all four sides' margin at once. If read, returns max
239    /// margin on any side.
240    ///
241    /// Readable | Writeable
242    ///
243    ///
244    /// #### `margin-bottom`
245    ///  Margin on bottom side of widget.
246    ///
247    /// This property adds margin outside of the widget's normal size
248    /// request, the margin will be added in addition to the size from
249    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
250    ///
251    /// Readable | Writeable
252    ///
253    ///
254    /// #### `margin-end`
255    ///  Margin on end of widget, horizontally. This property supports
256    /// left-to-right and right-to-left text directions.
257    ///
258    /// This property adds margin outside of the widget's normal size
259    /// request, the margin will be added in addition to the size from
260    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
261    ///
262    /// Readable | Writeable
263    ///
264    ///
265    /// #### `margin-left`
266    ///  Margin on left side of widget.
267    ///
268    /// This property adds margin outside of the widget's normal size
269    /// request, the margin will be added in addition to the size from
270    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
271    ///
272    /// Readable | Writeable
273    ///
274    ///
275    /// #### `margin-right`
276    ///  Margin on right side of widget.
277    ///
278    /// This property adds margin outside of the widget's normal size
279    /// request, the margin will be added in addition to the size from
280    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
281    ///
282    /// Readable | Writeable
283    ///
284    ///
285    /// #### `margin-start`
286    ///  Margin on start of widget, horizontally. This property supports
287    /// left-to-right and right-to-left text directions.
288    ///
289    /// This property adds margin outside of the widget's normal size
290    /// request, the margin will be added in addition to the size from
291    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
292    ///
293    /// Readable | Writeable
294    ///
295    ///
296    /// #### `margin-top`
297    ///  Margin on top side of widget.
298    ///
299    /// This property adds margin outside of the widget's normal size
300    /// request, the margin will be added in addition to the size from
301    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
302    ///
303    /// Readable | Writeable
304    ///
305    ///
306    /// #### `name`
307    ///  Readable | Writeable
308    ///
309    ///
310    /// #### `no-show-all`
311    ///  Readable | Writeable
312    ///
313    ///
314    /// #### `opacity`
315    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
316    /// more details about window opacity.
317    ///
318    /// Before 3.8 this was only available in GtkWindow
319    ///
320    /// Readable | Writeable
321    ///
322    ///
323    /// #### `parent`
324    ///  Readable | Writeable
325    ///
326    ///
327    /// #### `receives-default`
328    ///  Readable | Writeable
329    ///
330    ///
331    /// #### `scale-factor`
332    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
333    /// more details about widget scaling.
334    ///
335    /// Readable
336    ///
337    ///
338    /// #### `sensitive`
339    ///  Readable | Writeable
340    ///
341    ///
342    /// #### `style`
343    ///  The style of the widget, which contains information about how it will look (colors, etc).
344    ///
345    /// Readable | Writeable
346    ///
347    ///
348    /// #### `tooltip-markup`
349    ///  Sets the text of tooltip to be the given string, which is marked up
350    /// with the [Pango text markup language][PangoMarkupFormat].
351    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
352    ///
353    /// This is a convenience property which will take care of getting the
354    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
355    /// will automatically be set to [`true`] and there will be taken care of
356    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
357    ///
358    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
359    /// are set, the last one wins.
360    ///
361    /// Readable | Writeable
362    ///
363    ///
364    /// #### `tooltip-text`
365    ///  Sets the text of tooltip to be the given string.
366    ///
367    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
368    ///
369    /// This is a convenience property which will take care of getting the
370    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
371    /// will automatically be set to [`true`] and there will be taken care of
372    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
373    ///
374    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
375    /// are set, the last one wins.
376    ///
377    /// Readable | Writeable
378    ///
379    ///
380    /// #### `valign`
381    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
382    ///
383    /// Readable | Writeable
384    ///
385    ///
386    /// #### `vexpand`
387    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
388    ///
389    /// Readable | Writeable
390    ///
391    ///
392    /// #### `vexpand-set`
393    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
394    ///
395    /// Readable | Writeable
396    ///
397    ///
398    /// #### `visible`
399    ///  Readable | Writeable
400    ///
401    ///
402    /// #### `width-request`
403    ///  Readable | Writeable
404    ///
405    ///
406    /// #### `window`
407    ///  The widget's window if it is realized, [`None`] otherwise.
408    ///
409    /// Readable
410    /// </details>
411    /// <details><summary><h4>Actionable</h4></summary>
412    ///
413    ///
414    /// #### `action-name`
415    ///  Readable | Writeable
416    ///
417    ///
418    /// #### `action-target`
419    ///  Readable | Writeable
420    /// </details>
421    /// <details><summary><h4>Activatable</h4></summary>
422    ///
423    ///
424    /// #### `related-action`
425    ///  The action that this activatable will activate and receive
426    /// updates from for various states and possibly appearance.
427    ///
428    /// > `GtkActivatable` implementors need to handle the this property and
429    /// > call `gtk_activatable_do_set_related_action()` when it changes.
430    ///
431    /// Readable | Writeable
432    ///
433    ///
434    /// #### `use-action-appearance`
435    ///  Whether this activatable should reset its layout
436    /// and appearance when setting the related action or when
437    /// the action changes appearance.
438    ///
439    /// See the `GtkAction` documentation directly to find which properties
440    /// should be ignored by the `GtkActivatable` when this property is [`false`].
441    ///
442    /// > `GtkActivatable` implementors need to handle this property
443    /// > and call `gtk_activatable_sync_action_properties()` on the activatable
444    /// > widget when it changes.
445    ///
446    /// Readable | Writeable
447    /// </details>
448    ///
449    /// # Implements
450    ///
451    /// [`LockButtonExt`][trait@crate::prelude::LockButtonExt], [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
452    #[doc(alias = "GtkLockButton")]
453    pub struct LockButton(Object<ffi::GtkLockButton, ffi::GtkLockButtonClass>) @extends Button, Bin, Container, Widget, @implements Buildable, Actionable;
454
455    match fn {
456        type_ => || ffi::gtk_lock_button_get_type(),
457    }
458}
459
460impl LockButton {
461    pub const NONE: Option<&'static LockButton> = None;
462
463    /// Creates a new lock button which reflects the `permission`.
464    /// ## `permission`
465    /// a [`gio::Permission`][crate::gio::Permission]
466    ///
467    /// # Returns
468    ///
469    /// a new [`LockButton`][crate::LockButton]
470    #[doc(alias = "gtk_lock_button_new")]
471    pub fn new(permission: Option<&impl IsA<gio::Permission>>) -> LockButton {
472        assert_initialized_main_thread!();
473        unsafe {
474            Widget::from_glib_none(ffi::gtk_lock_button_new(
475                permission.map(|p| p.as_ref()).to_glib_none().0,
476            ))
477            .unsafe_cast()
478        }
479    }
480
481    // rustdoc-stripper-ignore-next
482    /// Creates a new builder-pattern struct instance to construct [`LockButton`] objects.
483    ///
484    /// This method returns an instance of [`LockButtonBuilder`](crate::builders::LockButtonBuilder) which can be used to create [`LockButton`] objects.
485    pub fn builder() -> LockButtonBuilder {
486        LockButtonBuilder::new()
487    }
488}
489
490impl Default for LockButton {
491    fn default() -> Self {
492        glib::object::Object::new::<Self>()
493    }
494}
495
496// rustdoc-stripper-ignore-next
497/// A [builder-pattern] type to construct [`LockButton`] objects.
498///
499/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
500#[must_use = "The builder must be built to be used"]
501pub struct LockButtonBuilder {
502    builder: glib::object::ObjectBuilder<'static, LockButton>,
503}
504
505impl LockButtonBuilder {
506    fn new() -> Self {
507        Self {
508            builder: glib::object::Object::builder(),
509        }
510    }
511
512    pub fn permission(self, permission: &impl IsA<gio::Permission>) -> Self {
513        Self {
514            builder: self
515                .builder
516                .property("permission", permission.clone().upcast()),
517        }
518    }
519
520    pub fn text_lock(self, text_lock: impl Into<glib::GString>) -> Self {
521        Self {
522            builder: self.builder.property("text-lock", text_lock.into()),
523        }
524    }
525
526    pub fn text_unlock(self, text_unlock: impl Into<glib::GString>) -> Self {
527        Self {
528            builder: self.builder.property("text-unlock", text_unlock.into()),
529        }
530    }
531
532    pub fn tooltip_lock(self, tooltip_lock: impl Into<glib::GString>) -> Self {
533        Self {
534            builder: self.builder.property("tooltip-lock", tooltip_lock.into()),
535        }
536    }
537
538    pub fn tooltip_not_authorized(self, tooltip_not_authorized: impl Into<glib::GString>) -> Self {
539        Self {
540            builder: self
541                .builder
542                .property("tooltip-not-authorized", tooltip_not_authorized.into()),
543        }
544    }
545
546    pub fn tooltip_unlock(self, tooltip_unlock: impl Into<glib::GString>) -> Self {
547        Self {
548            builder: self
549                .builder
550                .property("tooltip-unlock", tooltip_unlock.into()),
551        }
552    }
553
554    /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
555    /// setting and always show the image, if available.
556    ///
557    /// Use this property if the button would be useless or hard to use
558    /// without the image.
559    pub fn always_show_image(self, always_show_image: bool) -> Self {
560        Self {
561            builder: self
562                .builder
563                .property("always-show-image", always_show_image),
564        }
565    }
566
567    /// The child widget to appear next to the button text.
568    pub fn image(self, image: &impl IsA<Widget>) -> Self {
569        Self {
570            builder: self.builder.property("image", image.clone().upcast()),
571        }
572    }
573
574    /// The position of the image relative to the text inside the button.
575    pub fn image_position(self, image_position: PositionType) -> Self {
576        Self {
577            builder: self.builder.property("image-position", image_position),
578        }
579    }
580
581    pub fn label(self, label: impl Into<glib::GString>) -> Self {
582        Self {
583            builder: self.builder.property("label", label.into()),
584        }
585    }
586
587    pub fn relief(self, relief: ReliefStyle) -> Self {
588        Self {
589            builder: self.builder.property("relief", relief),
590        }
591    }
592
593    pub fn use_underline(self, use_underline: bool) -> Self {
594        Self {
595            builder: self.builder.property("use-underline", use_underline),
596        }
597    }
598
599    pub fn border_width(self, border_width: u32) -> Self {
600        Self {
601            builder: self.builder.property("border-width", border_width),
602        }
603    }
604
605    pub fn child(self, child: &impl IsA<Widget>) -> Self {
606        Self {
607            builder: self.builder.property("child", child.clone().upcast()),
608        }
609    }
610
611    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
612        Self {
613            builder: self.builder.property("resize-mode", resize_mode),
614        }
615    }
616
617    pub fn app_paintable(self, app_paintable: bool) -> Self {
618        Self {
619            builder: self.builder.property("app-paintable", app_paintable),
620        }
621    }
622
623    pub fn can_default(self, can_default: bool) -> Self {
624        Self {
625            builder: self.builder.property("can-default", can_default),
626        }
627    }
628
629    pub fn can_focus(self, can_focus: bool) -> Self {
630        Self {
631            builder: self.builder.property("can-focus", can_focus),
632        }
633    }
634
635    pub fn events(self, events: gdk::EventMask) -> Self {
636        Self {
637            builder: self.builder.property("events", events),
638        }
639    }
640
641    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
642    pub fn expand(self, expand: bool) -> Self {
643        Self {
644            builder: self.builder.property("expand", expand),
645        }
646    }
647
648    /// Whether the widget should grab focus when it is clicked with the mouse.
649    ///
650    /// This property is only relevant for widgets that can take focus.
651    ///
652    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
653    /// GtkComboBox) implemented this property individually.
654    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
655        Self {
656            builder: self.builder.property("focus-on-click", focus_on_click),
657        }
658    }
659
660    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
661    pub fn halign(self, halign: Align) -> Self {
662        Self {
663            builder: self.builder.property("halign", halign),
664        }
665    }
666
667    pub fn has_default(self, has_default: bool) -> Self {
668        Self {
669            builder: self.builder.property("has-default", has_default),
670        }
671    }
672
673    pub fn has_focus(self, has_focus: bool) -> Self {
674        Self {
675            builder: self.builder.property("has-focus", has_focus),
676        }
677    }
678
679    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
680    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
681    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
682    /// whether it will provide a tooltip or not.
683    ///
684    /// Note that setting this property to [`true`] for the first time will change
685    /// the event masks of the GdkWindows of this widget to include leave-notify
686    /// and motion-notify events. This cannot and will not be undone when the
687    /// property is set to [`false`] again.
688    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
689        Self {
690            builder: self.builder.property("has-tooltip", has_tooltip),
691        }
692    }
693
694    pub fn height_request(self, height_request: i32) -> Self {
695        Self {
696            builder: self.builder.property("height-request", height_request),
697        }
698    }
699
700    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
701    pub fn hexpand(self, hexpand: bool) -> Self {
702        Self {
703            builder: self.builder.property("hexpand", hexpand),
704        }
705    }
706
707    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
708    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
709        Self {
710            builder: self.builder.property("hexpand-set", hexpand_set),
711        }
712    }
713
714    pub fn is_focus(self, is_focus: bool) -> Self {
715        Self {
716            builder: self.builder.property("is-focus", is_focus),
717        }
718    }
719
720    /// Sets all four sides' margin at once. If read, returns max
721    /// margin on any side.
722    pub fn margin(self, margin: i32) -> Self {
723        Self {
724            builder: self.builder.property("margin", margin),
725        }
726    }
727
728    /// Margin on bottom side of widget.
729    ///
730    /// This property adds margin outside of the widget's normal size
731    /// request, the margin will be added in addition to the size from
732    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
733    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
734        Self {
735            builder: self.builder.property("margin-bottom", margin_bottom),
736        }
737    }
738
739    /// Margin on end of widget, horizontally. This property supports
740    /// left-to-right and right-to-left text directions.
741    ///
742    /// This property adds margin outside of the widget's normal size
743    /// request, the margin will be added in addition to the size from
744    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
745    pub fn margin_end(self, margin_end: i32) -> Self {
746        Self {
747            builder: self.builder.property("margin-end", margin_end),
748        }
749    }
750
751    /// Margin on start of widget, horizontally. This property supports
752    /// left-to-right and right-to-left text directions.
753    ///
754    /// This property adds margin outside of the widget's normal size
755    /// request, the margin will be added in addition to the size from
756    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
757    pub fn margin_start(self, margin_start: i32) -> Self {
758        Self {
759            builder: self.builder.property("margin-start", margin_start),
760        }
761    }
762
763    /// Margin on top side of widget.
764    ///
765    /// This property adds margin outside of the widget's normal size
766    /// request, the margin will be added in addition to the size from
767    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
768    pub fn margin_top(self, margin_top: i32) -> Self {
769        Self {
770            builder: self.builder.property("margin-top", margin_top),
771        }
772    }
773
774    pub fn name(self, name: impl Into<glib::GString>) -> Self {
775        Self {
776            builder: self.builder.property("name", name.into()),
777        }
778    }
779
780    pub fn no_show_all(self, no_show_all: bool) -> Self {
781        Self {
782            builder: self.builder.property("no-show-all", no_show_all),
783        }
784    }
785
786    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
787    /// more details about window opacity.
788    ///
789    /// Before 3.8 this was only available in GtkWindow
790    pub fn opacity(self, opacity: f64) -> Self {
791        Self {
792            builder: self.builder.property("opacity", opacity),
793        }
794    }
795
796    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
797        Self {
798            builder: self.builder.property("parent", parent.clone().upcast()),
799        }
800    }
801
802    pub fn receives_default(self, receives_default: bool) -> Self {
803        Self {
804            builder: self.builder.property("receives-default", receives_default),
805        }
806    }
807
808    pub fn sensitive(self, sensitive: bool) -> Self {
809        Self {
810            builder: self.builder.property("sensitive", sensitive),
811        }
812    }
813
814    /// Sets the text of tooltip to be the given string, which is marked up
815    /// with the [Pango text markup language][PangoMarkupFormat].
816    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
817    ///
818    /// This is a convenience property which will take care of getting the
819    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
820    /// will automatically be set to [`true`] and there will be taken care of
821    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
822    ///
823    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
824    /// are set, the last one wins.
825    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
826        Self {
827            builder: self
828                .builder
829                .property("tooltip-markup", tooltip_markup.into()),
830        }
831    }
832
833    /// Sets the text of tooltip to be the given string.
834    ///
835    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
836    ///
837    /// This is a convenience property which will take care of getting the
838    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
839    /// will automatically be set to [`true`] and there will be taken care of
840    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
841    ///
842    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
843    /// are set, the last one wins.
844    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
845        Self {
846            builder: self.builder.property("tooltip-text", tooltip_text.into()),
847        }
848    }
849
850    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
851    pub fn valign(self, valign: Align) -> Self {
852        Self {
853            builder: self.builder.property("valign", valign),
854        }
855    }
856
857    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
858    pub fn vexpand(self, vexpand: bool) -> Self {
859        Self {
860            builder: self.builder.property("vexpand", vexpand),
861        }
862    }
863
864    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
865    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
866        Self {
867            builder: self.builder.property("vexpand-set", vexpand_set),
868        }
869    }
870
871    pub fn visible(self, visible: bool) -> Self {
872        Self {
873            builder: self.builder.property("visible", visible),
874        }
875    }
876
877    pub fn width_request(self, width_request: i32) -> Self {
878        Self {
879            builder: self.builder.property("width-request", width_request),
880        }
881    }
882
883    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
884        Self {
885            builder: self.builder.property("action-name", action_name.into()),
886        }
887    }
888
889    pub fn action_target(self, action_target: &glib::Variant) -> Self {
890        Self {
891            builder: self
892                .builder
893                .property("action-target", action_target.clone()),
894        }
895    }
896
897    // rustdoc-stripper-ignore-next
898    /// Build the [`LockButton`].
899    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
900    pub fn build(self) -> LockButton {
901        self.builder.build()
902    }
903}
904
905mod sealed {
906    pub trait Sealed {}
907    impl<T: super::IsA<super::LockButton>> Sealed for T {}
908}
909
910/// Trait containing all [`struct@LockButton`] methods.
911///
912/// # Implementors
913///
914/// [`LockButton`][struct@crate::LockButton]
915pub trait LockButtonExt: IsA<LockButton> + sealed::Sealed + 'static {
916    /// Obtains the [`gio::Permission`][crate::gio::Permission] object that controls `self`.
917    ///
918    /// # Returns
919    ///
920    /// the [`gio::Permission`][crate::gio::Permission] of `self`
921    #[doc(alias = "gtk_lock_button_get_permission")]
922    #[doc(alias = "get_permission")]
923    fn permission(&self) -> Option<gio::Permission> {
924        unsafe {
925            from_glib_none(ffi::gtk_lock_button_get_permission(
926                self.as_ref().to_glib_none().0,
927            ))
928        }
929    }
930
931    /// Sets the [`gio::Permission`][crate::gio::Permission] object that controls `self`.
932    /// ## `permission`
933    /// a [`gio::Permission`][crate::gio::Permission] object, or [`None`]
934    #[doc(alias = "gtk_lock_button_set_permission")]
935    fn set_permission(&self, permission: Option<&impl IsA<gio::Permission>>) {
936        unsafe {
937            ffi::gtk_lock_button_set_permission(
938                self.as_ref().to_glib_none().0,
939                permission.map(|p| p.as_ref()).to_glib_none().0,
940            );
941        }
942    }
943
944    #[doc(alias = "text-lock")]
945    fn text_lock(&self) -> Option<glib::GString> {
946        ObjectExt::property(self.as_ref(), "text-lock")
947    }
948
949    #[doc(alias = "text-lock")]
950    fn set_text_lock(&self, text_lock: Option<&str>) {
951        ObjectExt::set_property(self.as_ref(), "text-lock", text_lock)
952    }
953
954    #[doc(alias = "text-unlock")]
955    fn text_unlock(&self) -> Option<glib::GString> {
956        ObjectExt::property(self.as_ref(), "text-unlock")
957    }
958
959    #[doc(alias = "text-unlock")]
960    fn set_text_unlock(&self, text_unlock: Option<&str>) {
961        ObjectExt::set_property(self.as_ref(), "text-unlock", text_unlock)
962    }
963
964    #[doc(alias = "tooltip-lock")]
965    fn tooltip_lock(&self) -> Option<glib::GString> {
966        ObjectExt::property(self.as_ref(), "tooltip-lock")
967    }
968
969    #[doc(alias = "tooltip-lock")]
970    fn set_tooltip_lock(&self, tooltip_lock: Option<&str>) {
971        ObjectExt::set_property(self.as_ref(), "tooltip-lock", tooltip_lock)
972    }
973
974    #[doc(alias = "tooltip-not-authorized")]
975    fn tooltip_not_authorized(&self) -> Option<glib::GString> {
976        ObjectExt::property(self.as_ref(), "tooltip-not-authorized")
977    }
978
979    #[doc(alias = "tooltip-not-authorized")]
980    fn set_tooltip_not_authorized(&self, tooltip_not_authorized: Option<&str>) {
981        ObjectExt::set_property(
982            self.as_ref(),
983            "tooltip-not-authorized",
984            tooltip_not_authorized,
985        )
986    }
987
988    #[doc(alias = "tooltip-unlock")]
989    fn tooltip_unlock(&self) -> Option<glib::GString> {
990        ObjectExt::property(self.as_ref(), "tooltip-unlock")
991    }
992
993    #[doc(alias = "tooltip-unlock")]
994    fn set_tooltip_unlock(&self, tooltip_unlock: Option<&str>) {
995        ObjectExt::set_property(self.as_ref(), "tooltip-unlock", tooltip_unlock)
996    }
997
998    #[doc(alias = "permission")]
999    fn connect_permission_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1000        unsafe extern "C" fn notify_permission_trampoline<
1001            P: IsA<LockButton>,
1002            F: Fn(&P) + 'static,
1003        >(
1004            this: *mut ffi::GtkLockButton,
1005            _param_spec: glib::ffi::gpointer,
1006            f: glib::ffi::gpointer,
1007        ) {
1008            let f: &F = &*(f as *const F);
1009            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1010        }
1011        unsafe {
1012            let f: Box_<F> = Box_::new(f);
1013            connect_raw(
1014                self.as_ptr() as *mut _,
1015                b"notify::permission\0".as_ptr() as *const _,
1016                Some(transmute::<_, unsafe extern "C" fn()>(
1017                    notify_permission_trampoline::<Self, F> as *const (),
1018                )),
1019                Box_::into_raw(f),
1020            )
1021        }
1022    }
1023
1024    #[doc(alias = "text-lock")]
1025    fn connect_text_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1026        unsafe extern "C" fn notify_text_lock_trampoline<
1027            P: IsA<LockButton>,
1028            F: Fn(&P) + 'static,
1029        >(
1030            this: *mut ffi::GtkLockButton,
1031            _param_spec: glib::ffi::gpointer,
1032            f: glib::ffi::gpointer,
1033        ) {
1034            let f: &F = &*(f as *const F);
1035            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1036        }
1037        unsafe {
1038            let f: Box_<F> = Box_::new(f);
1039            connect_raw(
1040                self.as_ptr() as *mut _,
1041                b"notify::text-lock\0".as_ptr() as *const _,
1042                Some(transmute::<_, unsafe extern "C" fn()>(
1043                    notify_text_lock_trampoline::<Self, F> as *const (),
1044                )),
1045                Box_::into_raw(f),
1046            )
1047        }
1048    }
1049
1050    #[doc(alias = "text-unlock")]
1051    fn connect_text_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1052        unsafe extern "C" fn notify_text_unlock_trampoline<
1053            P: IsA<LockButton>,
1054            F: Fn(&P) + 'static,
1055        >(
1056            this: *mut ffi::GtkLockButton,
1057            _param_spec: glib::ffi::gpointer,
1058            f: glib::ffi::gpointer,
1059        ) {
1060            let f: &F = &*(f as *const F);
1061            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1062        }
1063        unsafe {
1064            let f: Box_<F> = Box_::new(f);
1065            connect_raw(
1066                self.as_ptr() as *mut _,
1067                b"notify::text-unlock\0".as_ptr() as *const _,
1068                Some(transmute::<_, unsafe extern "C" fn()>(
1069                    notify_text_unlock_trampoline::<Self, F> as *const (),
1070                )),
1071                Box_::into_raw(f),
1072            )
1073        }
1074    }
1075
1076    #[doc(alias = "tooltip-lock")]
1077    fn connect_tooltip_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1078        unsafe extern "C" fn notify_tooltip_lock_trampoline<
1079            P: IsA<LockButton>,
1080            F: Fn(&P) + 'static,
1081        >(
1082            this: *mut ffi::GtkLockButton,
1083            _param_spec: glib::ffi::gpointer,
1084            f: glib::ffi::gpointer,
1085        ) {
1086            let f: &F = &*(f as *const F);
1087            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1088        }
1089        unsafe {
1090            let f: Box_<F> = Box_::new(f);
1091            connect_raw(
1092                self.as_ptr() as *mut _,
1093                b"notify::tooltip-lock\0".as_ptr() as *const _,
1094                Some(transmute::<_, unsafe extern "C" fn()>(
1095                    notify_tooltip_lock_trampoline::<Self, F> as *const (),
1096                )),
1097                Box_::into_raw(f),
1098            )
1099        }
1100    }
1101
1102    #[doc(alias = "tooltip-not-authorized")]
1103    fn connect_tooltip_not_authorized_notify<F: Fn(&Self) + 'static>(
1104        &self,
1105        f: F,
1106    ) -> SignalHandlerId {
1107        unsafe extern "C" fn notify_tooltip_not_authorized_trampoline<
1108            P: IsA<LockButton>,
1109            F: Fn(&P) + 'static,
1110        >(
1111            this: *mut ffi::GtkLockButton,
1112            _param_spec: glib::ffi::gpointer,
1113            f: glib::ffi::gpointer,
1114        ) {
1115            let f: &F = &*(f as *const F);
1116            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1117        }
1118        unsafe {
1119            let f: Box_<F> = Box_::new(f);
1120            connect_raw(
1121                self.as_ptr() as *mut _,
1122                b"notify::tooltip-not-authorized\0".as_ptr() as *const _,
1123                Some(transmute::<_, unsafe extern "C" fn()>(
1124                    notify_tooltip_not_authorized_trampoline::<Self, F> as *const (),
1125                )),
1126                Box_::into_raw(f),
1127            )
1128        }
1129    }
1130
1131    #[doc(alias = "tooltip-unlock")]
1132    fn connect_tooltip_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1133        unsafe extern "C" fn notify_tooltip_unlock_trampoline<
1134            P: IsA<LockButton>,
1135            F: Fn(&P) + 'static,
1136        >(
1137            this: *mut ffi::GtkLockButton,
1138            _param_spec: glib::ffi::gpointer,
1139            f: glib::ffi::gpointer,
1140        ) {
1141            let f: &F = &*(f as *const F);
1142            f(LockButton::from_glib_borrow(this).unsafe_cast_ref())
1143        }
1144        unsafe {
1145            let f: Box_<F> = Box_::new(f);
1146            connect_raw(
1147                self.as_ptr() as *mut _,
1148                b"notify::tooltip-unlock\0".as_ptr() as *const _,
1149                Some(transmute::<_, unsafe extern "C" fn()>(
1150                    notify_tooltip_unlock_trampoline::<Self, F> as *const (),
1151                )),
1152                Box_::into_raw(f),
1153            )
1154        }
1155    }
1156}
1157
1158impl<O: IsA<LockButton>> LockButtonExt for O {}
1159
1160impl fmt::Display for LockButton {
1161    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1162        f.write_str("LockButton")
1163    }
1164}