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