Skip to main content

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    Accessible, AccessibleRole, Actionable, Align, Buildable, Button, ConstraintTarget,
8    LayoutManager, Overflow, Widget, ffi,
9};
10use glib::{
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
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            unsafe {
665                let f: &F = &*(f as *const F);
666                f(&from_glib_borrow(this))
667            }
668        }
669        unsafe {
670            let f: Box_<F> = Box_::new(f);
671            connect_raw(
672                self.as_ptr() as *mut _,
673                c"notify::permission".as_ptr() as *const _,
674                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
675                    notify_permission_trampoline::<F> as *const (),
676                )),
677                Box_::into_raw(f),
678            )
679        }
680    }
681
682    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
683    #[doc(alias = "text-lock")]
684    pub fn connect_text_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
685        unsafe extern "C" fn notify_text_lock_trampoline<F: Fn(&LockButton) + 'static>(
686            this: *mut ffi::GtkLockButton,
687            _param_spec: glib::ffi::gpointer,
688            f: glib::ffi::gpointer,
689        ) {
690            unsafe {
691                let f: &F = &*(f as *const F);
692                f(&from_glib_borrow(this))
693            }
694        }
695        unsafe {
696            let f: Box_<F> = Box_::new(f);
697            connect_raw(
698                self.as_ptr() as *mut _,
699                c"notify::text-lock".as_ptr() as *const _,
700                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
701                    notify_text_lock_trampoline::<F> as *const (),
702                )),
703                Box_::into_raw(f),
704            )
705        }
706    }
707
708    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
709    #[doc(alias = "text-unlock")]
710    pub fn connect_text_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
711        unsafe extern "C" fn notify_text_unlock_trampoline<F: Fn(&LockButton) + 'static>(
712            this: *mut ffi::GtkLockButton,
713            _param_spec: glib::ffi::gpointer,
714            f: glib::ffi::gpointer,
715        ) {
716            unsafe {
717                let f: &F = &*(f as *const F);
718                f(&from_glib_borrow(this))
719            }
720        }
721        unsafe {
722            let f: Box_<F> = Box_::new(f);
723            connect_raw(
724                self.as_ptr() as *mut _,
725                c"notify::text-unlock".as_ptr() as *const _,
726                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
727                    notify_text_unlock_trampoline::<F> as *const (),
728                )),
729                Box_::into_raw(f),
730            )
731        }
732    }
733
734    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
735    #[doc(alias = "tooltip-lock")]
736    pub fn connect_tooltip_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
737        unsafe extern "C" fn notify_tooltip_lock_trampoline<F: Fn(&LockButton) + 'static>(
738            this: *mut ffi::GtkLockButton,
739            _param_spec: glib::ffi::gpointer,
740            f: glib::ffi::gpointer,
741        ) {
742            unsafe {
743                let f: &F = &*(f as *const F);
744                f(&from_glib_borrow(this))
745            }
746        }
747        unsafe {
748            let f: Box_<F> = Box_::new(f);
749            connect_raw(
750                self.as_ptr() as *mut _,
751                c"notify::tooltip-lock".as_ptr() as *const _,
752                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
753                    notify_tooltip_lock_trampoline::<F> as *const (),
754                )),
755                Box_::into_raw(f),
756            )
757        }
758    }
759
760    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
761    #[doc(alias = "tooltip-not-authorized")]
762    pub fn connect_tooltip_not_authorized_notify<F: Fn(&Self) + 'static>(
763        &self,
764        f: F,
765    ) -> SignalHandlerId {
766        unsafe extern "C" fn notify_tooltip_not_authorized_trampoline<
767            F: Fn(&LockButton) + 'static,
768        >(
769            this: *mut ffi::GtkLockButton,
770            _param_spec: glib::ffi::gpointer,
771            f: glib::ffi::gpointer,
772        ) {
773            unsafe {
774                let f: &F = &*(f as *const F);
775                f(&from_glib_borrow(this))
776            }
777        }
778        unsafe {
779            let f: Box_<F> = Box_::new(f);
780            connect_raw(
781                self.as_ptr() as *mut _,
782                c"notify::tooltip-not-authorized".as_ptr() as *const _,
783                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
784                    notify_tooltip_not_authorized_trampoline::<F> as *const (),
785                )),
786                Box_::into_raw(f),
787            )
788        }
789    }
790
791    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
792    #[doc(alias = "tooltip-unlock")]
793    pub fn connect_tooltip_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
794        unsafe extern "C" fn notify_tooltip_unlock_trampoline<F: Fn(&LockButton) + 'static>(
795            this: *mut ffi::GtkLockButton,
796            _param_spec: glib::ffi::gpointer,
797            f: glib::ffi::gpointer,
798        ) {
799            unsafe {
800                let f: &F = &*(f as *const F);
801                f(&from_glib_borrow(this))
802            }
803        }
804        unsafe {
805            let f: Box_<F> = Box_::new(f);
806            connect_raw(
807                self.as_ptr() as *mut _,
808                c"notify::tooltip-unlock".as_ptr() as *const _,
809                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
810                    notify_tooltip_unlock_trampoline::<F> as *const (),
811                )),
812                Box_::into_raw(f),
813            )
814        }
815    }
816}
817
818impl Default for LockButton {
819    fn default() -> Self {
820        glib::object::Object::new::<Self>()
821    }
822}
823
824// rustdoc-stripper-ignore-next
825/// A [builder-pattern] type to construct [`LockButton`] objects.
826///
827/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
828#[must_use = "The builder must be built to be used"]
829pub struct LockButtonBuilder {
830    builder: glib::object::ObjectBuilder<'static, LockButton>,
831}
832
833impl LockButtonBuilder {
834    fn new() -> Self {
835        Self {
836            builder: glib::object::Object::builder(),
837        }
838    }
839
840    /// The `GPermission object controlling this button.
841    /// This widget will be removed in GTK 5
842    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
843    pub fn permission(self, permission: &impl IsA<gio::Permission>) -> Self {
844        Self {
845            builder: self
846                .builder
847                .property("permission", permission.clone().upcast()),
848        }
849    }
850
851    /// The text to display when prompting the user to lock.
852    /// This widget will be removed in GTK 5
853    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
854    pub fn text_lock(self, text_lock: impl Into<glib::GString>) -> Self {
855        Self {
856            builder: self.builder.property("text-lock", text_lock.into()),
857        }
858    }
859
860    /// The text to display when prompting the user to unlock.
861    /// This widget will be removed in GTK 5
862    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
863    pub fn text_unlock(self, text_unlock: impl Into<glib::GString>) -> Self {
864        Self {
865            builder: self.builder.property("text-unlock", text_unlock.into()),
866        }
867    }
868
869    /// The tooltip to display when prompting the user to lock.
870    /// This widget will be removed in GTK 5
871    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
872    pub fn tooltip_lock(self, tooltip_lock: impl Into<glib::GString>) -> Self {
873        Self {
874            builder: self.builder.property("tooltip-lock", tooltip_lock.into()),
875        }
876    }
877
878    /// The tooltip to display when the user cannot obtain authorization.
879    /// This widget will be removed in GTK 5
880    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
881    pub fn tooltip_not_authorized(self, tooltip_not_authorized: impl Into<glib::GString>) -> Self {
882        Self {
883            builder: self
884                .builder
885                .property("tooltip-not-authorized", tooltip_not_authorized.into()),
886        }
887    }
888
889    /// The tooltip to display when prompting the user to unlock.
890    /// This widget will be removed in GTK 5
891    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
892    pub fn tooltip_unlock(self, tooltip_unlock: impl Into<glib::GString>) -> Self {
893        Self {
894            builder: self
895                .builder
896                .property("tooltip-unlock", tooltip_unlock.into()),
897        }
898    }
899
900    /// Whether the size of the button can be made smaller than the natural
901    /// size of its contents.
902    ///
903    /// For text buttons, setting this property will allow ellipsizing the label.
904    ///
905    /// If the contents of a button are an icon or a custom widget, setting this
906    /// property has no effect.
907    #[cfg(feature = "v4_12")]
908    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
909    pub fn can_shrink(self, can_shrink: bool) -> Self {
910        Self {
911            builder: self.builder.property("can-shrink", can_shrink),
912        }
913    }
914
915    /// The child widget.
916    pub fn child(self, child: &impl IsA<Widget>) -> Self {
917        Self {
918            builder: self.builder.property("child", child.clone().upcast()),
919        }
920    }
921
922    /// Whether the button has a frame.
923    pub fn has_frame(self, has_frame: bool) -> Self {
924        Self {
925            builder: self.builder.property("has-frame", has_frame),
926        }
927    }
928
929    /// The name of the icon used to automatically populate the button.
930    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
931        Self {
932            builder: self.builder.property("icon-name", icon_name.into()),
933        }
934    }
935
936    /// Text of the label inside the button, if the button contains a label widget.
937    pub fn label(self, label: impl Into<glib::GString>) -> Self {
938        Self {
939            builder: self.builder.property("label", label.into()),
940        }
941    }
942
943    /// If set, an underline in the text indicates that the following character is
944    /// to be used as mnemonic.
945    pub fn use_underline(self, use_underline: bool) -> Self {
946        Self {
947            builder: self.builder.property("use-underline", use_underline),
948        }
949    }
950
951    /// Whether the widget or any of its descendents can accept
952    /// the input focus.
953    ///
954    /// This property is meant to be set by widget implementations,
955    /// typically in their instance init function.
956    pub fn can_focus(self, can_focus: bool) -> Self {
957        Self {
958            builder: self.builder.property("can-focus", can_focus),
959        }
960    }
961
962    /// Whether the widget can receive pointer events.
963    pub fn can_target(self, can_target: bool) -> Self {
964        Self {
965            builder: self.builder.property("can-target", can_target),
966        }
967    }
968
969    /// A list of css classes applied to this widget.
970    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
971        Self {
972            builder: self.builder.property("css-classes", css_classes.into()),
973        }
974    }
975
976    /// The name of this widget in the CSS tree.
977    ///
978    /// This property is meant to be set by widget implementations,
979    /// typically in their instance init function.
980    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
981        Self {
982            builder: self.builder.property("css-name", css_name.into()),
983        }
984    }
985
986    /// The cursor used by @widget.
987    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
988        Self {
989            builder: self.builder.property("cursor", cursor.clone()),
990        }
991    }
992
993    /// Whether the widget should grab focus when it is clicked with the mouse.
994    ///
995    /// This property is only relevant for widgets that can take focus.
996    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
997        Self {
998            builder: self.builder.property("focus-on-click", focus_on_click),
999        }
1000    }
1001
1002    /// Whether this widget itself will accept the input focus.
1003    pub fn focusable(self, focusable: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("focusable", focusable),
1006        }
1007    }
1008
1009    /// How to distribute horizontal space if widget gets extra space.
1010    pub fn halign(self, halign: Align) -> Self {
1011        Self {
1012            builder: self.builder.property("halign", halign),
1013        }
1014    }
1015
1016    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1017    /// signal on @widget.
1018    ///
1019    /// A true value indicates that @widget can have a tooltip, in this case
1020    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1021    /// determine whether it will provide a tooltip or not.
1022    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1023        Self {
1024            builder: self.builder.property("has-tooltip", has_tooltip),
1025        }
1026    }
1027
1028    /// Overrides for height request of the widget.
1029    ///
1030    /// If this is -1, the natural request will be used.
1031    pub fn height_request(self, height_request: i32) -> Self {
1032        Self {
1033            builder: self.builder.property("height-request", height_request),
1034        }
1035    }
1036
1037    /// Whether to expand horizontally.
1038    pub fn hexpand(self, hexpand: bool) -> Self {
1039        Self {
1040            builder: self.builder.property("hexpand", hexpand),
1041        }
1042    }
1043
1044    /// Whether to use the `hexpand` property.
1045    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1046        Self {
1047            builder: self.builder.property("hexpand-set", hexpand_set),
1048        }
1049    }
1050
1051    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1052    /// the preferred size of the widget, and allocate its children.
1053    ///
1054    /// This property is meant to be set by widget implementations,
1055    /// typically in their instance init function.
1056    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1057        Self {
1058            builder: self
1059                .builder
1060                .property("layout-manager", layout_manager.clone().upcast()),
1061        }
1062    }
1063
1064    /// Makes this widget act like a modal dialog, with respect to
1065    /// event delivery.
1066    ///
1067    /// Global event controllers will not handle events with targets
1068    /// inside the widget, unless they are set up to ignore propagation
1069    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1070    #[cfg(feature = "v4_18")]
1071    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1072    pub fn limit_events(self, limit_events: bool) -> Self {
1073        Self {
1074            builder: self.builder.property("limit-events", limit_events),
1075        }
1076    }
1077
1078    /// Margin on bottom side of widget.
1079    ///
1080    /// This property adds margin outside of the widget's normal size
1081    /// request, the margin will be added in addition to the size from
1082    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1083    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1084        Self {
1085            builder: self.builder.property("margin-bottom", margin_bottom),
1086        }
1087    }
1088
1089    /// Margin on end of widget, horizontally.
1090    ///
1091    /// This property supports left-to-right and right-to-left text
1092    /// directions.
1093    ///
1094    /// This property adds margin outside of the widget's normal size
1095    /// request, the margin will be added in addition to the size from
1096    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1097    pub fn margin_end(self, margin_end: i32) -> Self {
1098        Self {
1099            builder: self.builder.property("margin-end", margin_end),
1100        }
1101    }
1102
1103    /// Margin on start of widget, horizontally.
1104    ///
1105    /// This property supports left-to-right and right-to-left text
1106    /// directions.
1107    ///
1108    /// This property adds margin outside of the widget's normal size
1109    /// request, the margin will be added in addition to the size from
1110    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1111    pub fn margin_start(self, margin_start: i32) -> Self {
1112        Self {
1113            builder: self.builder.property("margin-start", margin_start),
1114        }
1115    }
1116
1117    /// Margin on top side of widget.
1118    ///
1119    /// This property adds margin outside of the widget's normal size
1120    /// request, the margin will be added in addition to the size from
1121    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1122    pub fn margin_top(self, margin_top: i32) -> Self {
1123        Self {
1124            builder: self.builder.property("margin-top", margin_top),
1125        }
1126    }
1127
1128    /// The name of the widget.
1129    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1130        Self {
1131            builder: self.builder.property("name", name.into()),
1132        }
1133    }
1134
1135    /// The requested opacity of the widget.
1136    pub fn opacity(self, opacity: f64) -> Self {
1137        Self {
1138            builder: self.builder.property("opacity", opacity),
1139        }
1140    }
1141
1142    /// How content outside the widget's content area is treated.
1143    ///
1144    /// This property is meant to be set by widget implementations,
1145    /// typically in their instance init function.
1146    pub fn overflow(self, overflow: Overflow) -> Self {
1147        Self {
1148            builder: self.builder.property("overflow", overflow),
1149        }
1150    }
1151
1152    /// Whether the widget will receive the default action when it is focused.
1153    pub fn receives_default(self, receives_default: bool) -> Self {
1154        Self {
1155            builder: self.builder.property("receives-default", receives_default),
1156        }
1157    }
1158
1159    /// Whether the widget responds to input.
1160    pub fn sensitive(self, sensitive: bool) -> Self {
1161        Self {
1162            builder: self.builder.property("sensitive", sensitive),
1163        }
1164    }
1165
1166    /// Sets the text of tooltip to be the given string, which is marked up
1167    /// with Pango markup.
1168    ///
1169    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1170    ///
1171    /// This is a convenience property which will take care of getting the
1172    /// tooltip shown if the given string is not `NULL`:
1173    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1174    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1175    /// the default signal handler.
1176    ///
1177    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1178    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1179    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1180        Self {
1181            builder: self
1182                .builder
1183                .property("tooltip-markup", tooltip_markup.into()),
1184        }
1185    }
1186
1187    /// Sets the text of tooltip to be the given string.
1188    ///
1189    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1190    ///
1191    /// This is a convenience property which will take care of getting the
1192    /// tooltip shown if the given string is not `NULL`:
1193    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1194    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1195    /// the default signal handler.
1196    ///
1197    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1198    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1199    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1200        Self {
1201            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1202        }
1203    }
1204
1205    /// How to distribute vertical space if widget gets extra space.
1206    pub fn valign(self, valign: Align) -> Self {
1207        Self {
1208            builder: self.builder.property("valign", valign),
1209        }
1210    }
1211
1212    /// Whether to expand vertically.
1213    pub fn vexpand(self, vexpand: bool) -> Self {
1214        Self {
1215            builder: self.builder.property("vexpand", vexpand),
1216        }
1217    }
1218
1219    /// Whether to use the `vexpand` property.
1220    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1221        Self {
1222            builder: self.builder.property("vexpand-set", vexpand_set),
1223        }
1224    }
1225
1226    /// Whether the widget is visible.
1227    pub fn visible(self, visible: bool) -> Self {
1228        Self {
1229            builder: self.builder.property("visible", visible),
1230        }
1231    }
1232
1233    /// Overrides for width request of the widget.
1234    ///
1235    /// If this is -1, the natural request will be used.
1236    pub fn width_request(self, width_request: i32) -> Self {
1237        Self {
1238            builder: self.builder.property("width-request", width_request),
1239        }
1240    }
1241
1242    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1243    ///
1244    /// The accessible role cannot be changed once set.
1245    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1246        Self {
1247            builder: self.builder.property("accessible-role", accessible_role),
1248        }
1249    }
1250
1251    /// The name of the action with which this widget should be associated.
1252    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1253        Self {
1254            builder: self.builder.property("action-name", action_name.into()),
1255        }
1256    }
1257
1258    /// The target value of the actionable widget's action.
1259    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1260        Self {
1261            builder: self
1262                .builder
1263                .property("action-target", action_target.clone()),
1264        }
1265    }
1266
1267    // rustdoc-stripper-ignore-next
1268    /// Build the [`LockButton`].
1269    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1270    pub fn build(self) -> LockButton {
1271        assert_initialized_main_thread!();
1272        self.builder.build()
1273    }
1274}