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