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