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 ///
25 ///
26 /// If the user has the permission and cannot drop it, the button is hidden.
27 ///
28 /// The text (and tooltips) that are shown in the various cases can be adjusted
29 /// with the [`text-lock`][struct@crate::LockButton#text-lock],
30 /// [`text-unlock`][struct@crate::LockButton#text-unlock],
31 /// [`tooltip-lock`][struct@crate::LockButton#tooltip-lock],
32 /// [`tooltip-unlock`][struct@crate::LockButton#tooltip-unlock] and
33 /// [`tooltip-not-authorized`][struct@crate::LockButton#tooltip-not-authorized] properties.
34 ///
35 /// ## Properties
36 ///
37 ///
38 /// #### `permission`
39 /// The `GPermission object controlling this button.
40 ///
41 /// Readable | Writable
42 ///
43 ///
44 /// #### `text-lock`
45 /// The text to display when prompting the user to lock.
46 ///
47 /// Readable | Writable | Construct
48 ///
49 ///
50 /// #### `text-unlock`
51 /// The text to display when prompting the user to unlock.
52 ///
53 /// Readable | Writable | Construct
54 ///
55 ///
56 /// #### `tooltip-lock`
57 /// The tooltip to display when prompting the user to lock.
58 ///
59 /// Readable | Writable | Construct
60 ///
61 ///
62 /// #### `tooltip-not-authorized`
63 /// The tooltip to display when the user cannot obtain authorization.
64 ///
65 /// Readable | Writable | Construct
66 ///
67 ///
68 /// #### `tooltip-unlock`
69 /// The tooltip to display when prompting the user to unlock.
70 ///
71 /// Readable | Writable | Construct
72 /// <details><summary><h4>Button</h4></summary>
73 ///
74 ///
75 /// #### `can-shrink`
76 /// Whether the size of the button can be made smaller than the natural
77 /// size of its contents.
78 ///
79 /// For text buttons, setting this property will allow ellipsizing the label.
80 ///
81 /// If the contents of a button are an icon or a custom widget, setting this
82 /// property has no effect.
83 ///
84 /// Readable | Writable
85 ///
86 ///
87 /// #### `child`
88 /// The child widget.
89 ///
90 /// Readable | Writable
91 ///
92 ///
93 /// #### `has-frame`
94 /// Whether the button has a frame.
95 ///
96 /// Readable | Writable
97 ///
98 ///
99 /// #### `icon-name`
100 /// The name of the icon used to automatically populate the button.
101 ///
102 /// Readable | Writable
103 ///
104 ///
105 /// #### `label`
106 /// Text of the label inside the button, if the button contains a label widget.
107 ///
108 /// Readable | Writable
109 ///
110 ///
111 /// #### `use-underline`
112 /// If set, an underline in the text indicates that the following character is
113 /// to be used as mnemonic.
114 ///
115 /// Readable | Writable
116 /// </details>
117 /// <details><summary><h4>Widget</h4></summary>
118 ///
119 ///
120 /// #### `can-focus`
121 /// Whether the widget or any of its descendents can accept
122 /// the input focus.
123 ///
124 /// This property is meant to be set by widget implementations,
125 /// typically in their instance init function.
126 ///
127 /// Readable | Writable
128 ///
129 ///
130 /// #### `can-target`
131 /// Whether the widget can receive pointer events.
132 ///
133 /// Readable | Writable
134 ///
135 ///
136 /// #### `css-classes`
137 /// A list of css classes applied to this widget.
138 ///
139 /// Readable | Writable
140 ///
141 ///
142 /// #### `css-name`
143 /// The name of this widget in the CSS tree.
144 ///
145 /// This property is meant to be set by widget implementations,
146 /// typically in their instance init function.
147 ///
148 /// Readable | Writable | Construct Only
149 ///
150 ///
151 /// #### `cursor`
152 /// The cursor used by @widget.
153 ///
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `focus-on-click`
158 /// Whether the widget should grab focus when it is clicked with the mouse.
159 ///
160 /// This property is only relevant for widgets that can take focus.
161 ///
162 /// Readable | Writable
163 ///
164 ///
165 /// #### `focusable`
166 /// Whether this widget itself will accept the input focus.
167 ///
168 /// Readable | Writable
169 ///
170 ///
171 /// #### `halign`
172 /// How to distribute horizontal space if widget gets extra space.
173 ///
174 /// Readable | Writable
175 ///
176 ///
177 /// #### `has-default`
178 /// Whether the widget is the default widget.
179 ///
180 /// Readable
181 ///
182 ///
183 /// #### `has-focus`
184 /// Whether the widget has the input focus.
185 ///
186 /// Readable
187 ///
188 ///
189 /// #### `has-tooltip`
190 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
191 /// signal on @widget.
192 ///
193 /// A true value indicates that @widget can have a tooltip, in this case
194 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
195 /// determine whether it will provide a tooltip or not.
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `height-request`
201 /// Overrides for height request of the widget.
202 ///
203 /// If this is -1, the natural request will be used.
204 ///
205 /// Readable | Writable
206 ///
207 ///
208 /// #### `hexpand`
209 /// Whether to expand horizontally.
210 ///
211 /// Readable | Writable
212 ///
213 ///
214 /// #### `hexpand-set`
215 /// Whether to use the `hexpand` property.
216 ///
217 /// Readable | Writable
218 ///
219 ///
220 /// #### `layout-manager`
221 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
222 /// the preferred size of the widget, and allocate its children.
223 ///
224 /// This property is meant to be set by widget implementations,
225 /// typically in their instance init function.
226 ///
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `limit-events`
231 /// Makes this widget act like a modal dialog, with respect to
232 /// event delivery.
233 ///
234 /// Global event controllers will not handle events with targets
235 /// inside the widget, unless they are set up to ignore propagation
236 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
237 ///
238 /// Readable | Writable
239 ///
240 ///
241 /// #### `margin-bottom`
242 /// Margin on bottom side of widget.
243 ///
244 /// This property adds margin outside of the widget's normal size
245 /// request, the margin will be added in addition to the size from
246 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
247 ///
248 /// Readable | Writable
249 ///
250 ///
251 /// #### `margin-end`
252 /// Margin on end of widget, horizontally.
253 ///
254 /// This property supports left-to-right and right-to-left text
255 /// directions.
256 ///
257 /// This property adds margin outside of the widget's normal size
258 /// request, the margin will be added in addition to the size from
259 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
260 ///
261 /// Readable | Writable
262 ///
263 ///
264 /// #### `margin-start`
265 /// Margin on start of widget, horizontally.
266 ///
267 /// This property supports left-to-right and right-to-left text
268 /// directions.
269 ///
270 /// This property adds margin outside of the widget's normal size
271 /// request, the margin will be added in addition to the size from
272 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
273 ///
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `margin-top`
278 /// Margin on top side of widget.
279 ///
280 /// This property adds margin outside of the widget's normal size
281 /// request, the margin will be added in addition to the size from
282 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
283 ///
284 /// Readable | Writable
285 ///
286 ///
287 /// #### `name`
288 /// The name of the widget.
289 ///
290 /// Readable | Writable
291 ///
292 ///
293 /// #### `opacity`
294 /// The requested opacity of the widget.
295 ///
296 /// Readable | Writable
297 ///
298 ///
299 /// #### `overflow`
300 /// How content outside the widget's content area is treated.
301 ///
302 /// This property is meant to be set by widget implementations,
303 /// typically in their instance init function.
304 ///
305 /// Readable | Writable
306 ///
307 ///
308 /// #### `parent`
309 /// The parent widget of this widget.
310 ///
311 /// Readable
312 ///
313 ///
314 /// #### `receives-default`
315 /// Whether the widget will receive the default action when it is focused.
316 ///
317 /// Readable | Writable
318 ///
319 ///
320 /// #### `root`
321 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
322 ///
323 /// This will be `NULL` if the widget is not contained in a root widget.
324 ///
325 /// Readable
326 ///
327 ///
328 /// #### `scale-factor`
329 /// The scale factor of the widget.
330 ///
331 /// Readable
332 ///
333 ///
334 /// #### `sensitive`
335 /// Whether the widget responds to input.
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `tooltip-markup`
341 /// Sets the text of tooltip to be the given string, which is marked up
342 /// with Pango markup.
343 ///
344 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
345 ///
346 /// This is a convenience property which will take care of getting the
347 /// tooltip shown if the given string is not `NULL`:
348 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
349 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
350 /// the default signal handler.
351 ///
352 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
353 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
354 ///
355 /// Readable | Writable
356 ///
357 ///
358 /// #### `tooltip-text`
359 /// Sets the text of tooltip to be the given string.
360 ///
361 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
362 ///
363 /// This is a convenience property which will take care of getting the
364 /// tooltip shown if the given string is not `NULL`:
365 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
366 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
367 /// the default signal handler.
368 ///
369 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
370 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
371 ///
372 /// Readable | Writable
373 ///
374 ///
375 /// #### `valign`
376 /// How to distribute vertical space if widget gets extra space.
377 ///
378 /// Readable | Writable
379 ///
380 ///
381 /// #### `vexpand`
382 /// Whether to expand vertically.
383 ///
384 /// Readable | Writable
385 ///
386 ///
387 /// #### `vexpand-set`
388 /// Whether to use the `vexpand` property.
389 ///
390 /// Readable | Writable
391 ///
392 ///
393 /// #### `visible`
394 /// Whether the widget is visible.
395 ///
396 /// Readable | Writable
397 ///
398 ///
399 /// #### `width-request`
400 /// Overrides for width request of the widget.
401 ///
402 /// If this is -1, the natural request will be used.
403 ///
404 /// Readable | Writable
405 /// </details>
406 /// <details><summary><h4>Accessible</h4></summary>
407 ///
408 ///
409 /// #### `accessible-role`
410 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
411 ///
412 /// The accessible role cannot be changed once set.
413 ///
414 /// Readable | Writable
415 /// </details>
416 /// <details><summary><h4>Actionable</h4></summary>
417 ///
418 ///
419 /// #### `action-name`
420 /// The name of the action with which this widget should be associated.
421 ///
422 /// Readable | Writable
423 ///
424 ///
425 /// #### `action-target`
426 /// The target value of the actionable widget's action.
427 ///
428 /// Readable | Writable
429 /// </details>
430 ///
431 /// # Implements
432 ///
433 /// [`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]
434 #[doc(alias = "GtkLockButton")]
435 pub struct LockButton(Object<ffi::GtkLockButton>) @extends Button, Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable;
436
437 match fn {
438 type_ => || ffi::gtk_lock_button_get_type(),
439 }
440}
441
442#[cfg(not(feature = "v4_10"))]
443glib::wrapper! {
444 #[doc(alias = "GtkLockButton")]
445 pub struct LockButton(Object<ffi::GtkLockButton>) @extends Button, Widget, @implements Buildable, ConstraintTarget, Actionable;
446
447 match fn {
448 type_ => || ffi::gtk_lock_button_get_type(),
449 }
450}
451
452impl LockButton {
453 /// Creates a new lock button which reflects the @permission.
454 ///
455 /// # Deprecated since 4.10
456 ///
457 /// This widget will be removed in GTK 5
458 /// ## `permission`
459 /// a `GPermission`
460 ///
461 /// # Returns
462 ///
463 /// a new [`LockButton`][crate::LockButton]
464 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
465 #[allow(deprecated)]
466 #[doc(alias = "gtk_lock_button_new")]
467 pub fn new(permission: Option<&impl IsA<gio::Permission>>) -> LockButton {
468 assert_initialized_main_thread!();
469 unsafe {
470 Widget::from_glib_none(ffi::gtk_lock_button_new(
471 permission.map(|p| p.as_ref()).to_glib_none().0,
472 ))
473 .unsafe_cast()
474 }
475 }
476
477 // rustdoc-stripper-ignore-next
478 /// Creates a new builder-pattern struct instance to construct [`LockButton`] objects.
479 ///
480 /// This method returns an instance of [`LockButtonBuilder`](crate::builders::LockButtonBuilder) which can be used to create [`LockButton`] objects.
481 pub fn builder() -> LockButtonBuilder {
482 LockButtonBuilder::new()
483 }
484
485 /// Obtains the `GPermission` object that controls @self.
486 ///
487 /// # Deprecated since 4.10
488 ///
489 /// This widget will be removed in GTK 5
490 ///
491 /// # Returns
492 ///
493 /// the `GPermission` of @self
494 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
495 #[allow(deprecated)]
496 #[doc(alias = "gtk_lock_button_get_permission")]
497 #[doc(alias = "get_permission")]
498 pub fn permission(&self) -> Option<gio::Permission> {
499 unsafe { from_glib_none(ffi::gtk_lock_button_get_permission(self.to_glib_none().0)) }
500 }
501
502 /// Sets the `GPermission` object that controls @self.
503 ///
504 /// # Deprecated since 4.10
505 ///
506 /// This widget will be removed in GTK 5
507 /// ## `permission`
508 /// a `GPermission` object
509 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
510 #[allow(deprecated)]
511 #[doc(alias = "gtk_lock_button_set_permission")]
512 #[doc(alias = "permission")]
513 pub fn set_permission(&self, permission: Option<&impl IsA<gio::Permission>>) {
514 unsafe {
515 ffi::gtk_lock_button_set_permission(
516 self.to_glib_none().0,
517 permission.map(|p| p.as_ref()).to_glib_none().0,
518 );
519 }
520 }
521
522 /// The text to display when prompting the user to lock.
523 ///
524 /// # Deprecated since 4.10
525 ///
526 /// This widget will be removed in GTK 5
527 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
528 #[doc(alias = "text-lock")]
529 pub fn text_lock(&self) -> Option<glib::GString> {
530 ObjectExt::property(self, "text-lock")
531 }
532
533 /// The text to display when prompting the user to lock.
534 ///
535 /// # Deprecated since 4.10
536 ///
537 /// This widget will be removed in GTK 5
538 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
539 #[doc(alias = "text-lock")]
540 pub fn set_text_lock(&self, text_lock: Option<&str>) {
541 ObjectExt::set_property(self, "text-lock", text_lock)
542 }
543
544 /// The text to display when prompting the user to unlock.
545 ///
546 /// # Deprecated since 4.10
547 ///
548 /// This widget will be removed in GTK 5
549 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
550 #[doc(alias = "text-unlock")]
551 pub fn text_unlock(&self) -> Option<glib::GString> {
552 ObjectExt::property(self, "text-unlock")
553 }
554
555 /// The text to display when prompting the user to unlock.
556 ///
557 /// # Deprecated since 4.10
558 ///
559 /// This widget will be removed in GTK 5
560 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
561 #[doc(alias = "text-unlock")]
562 pub fn set_text_unlock(&self, text_unlock: Option<&str>) {
563 ObjectExt::set_property(self, "text-unlock", text_unlock)
564 }
565
566 /// The tooltip to display when prompting the user to lock.
567 ///
568 /// # Deprecated since 4.10
569 ///
570 /// This widget will be removed in GTK 5
571 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
572 #[doc(alias = "tooltip-lock")]
573 pub fn tooltip_lock(&self) -> Option<glib::GString> {
574 ObjectExt::property(self, "tooltip-lock")
575 }
576
577 /// The tooltip to display when prompting the user to lock.
578 ///
579 /// # Deprecated since 4.10
580 ///
581 /// This widget will be removed in GTK 5
582 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
583 #[doc(alias = "tooltip-lock")]
584 pub fn set_tooltip_lock(&self, tooltip_lock: Option<&str>) {
585 ObjectExt::set_property(self, "tooltip-lock", tooltip_lock)
586 }
587
588 /// The tooltip to display when the user cannot obtain authorization.
589 ///
590 /// # Deprecated since 4.10
591 ///
592 /// This widget will be removed in GTK 5
593 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
594 #[doc(alias = "tooltip-not-authorized")]
595 pub fn tooltip_not_authorized(&self) -> Option<glib::GString> {
596 ObjectExt::property(self, "tooltip-not-authorized")
597 }
598
599 /// The tooltip to display when the user cannot obtain authorization.
600 ///
601 /// # Deprecated since 4.10
602 ///
603 /// This widget will be removed in GTK 5
604 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
605 #[doc(alias = "tooltip-not-authorized")]
606 pub fn set_tooltip_not_authorized(&self, tooltip_not_authorized: Option<&str>) {
607 ObjectExt::set_property(self, "tooltip-not-authorized", tooltip_not_authorized)
608 }
609
610 /// The tooltip to display when prompting the user to unlock.
611 ///
612 /// # Deprecated since 4.10
613 ///
614 /// This widget will be removed in GTK 5
615 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
616 #[doc(alias = "tooltip-unlock")]
617 pub fn tooltip_unlock(&self) -> Option<glib::GString> {
618 ObjectExt::property(self, "tooltip-unlock")
619 }
620
621 /// The tooltip to display when prompting the user to unlock.
622 ///
623 /// # Deprecated since 4.10
624 ///
625 /// This widget will be removed in GTK 5
626 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
627 #[doc(alias = "tooltip-unlock")]
628 pub fn set_tooltip_unlock(&self, tooltip_unlock: Option<&str>) {
629 ObjectExt::set_property(self, "tooltip-unlock", tooltip_unlock)
630 }
631
632 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
633 #[doc(alias = "permission")]
634 pub fn connect_permission_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
635 unsafe extern "C" fn notify_permission_trampoline<F: Fn(&LockButton) + 'static>(
636 this: *mut ffi::GtkLockButton,
637 _param_spec: glib::ffi::gpointer,
638 f: glib::ffi::gpointer,
639 ) {
640 unsafe {
641 let f: &F = &*(f as *const F);
642 f(&from_glib_borrow(this))
643 }
644 }
645 unsafe {
646 let f: Box_<F> = Box_::new(f);
647 connect_raw(
648 self.as_ptr() as *mut _,
649 c"notify::permission".as_ptr(),
650 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
651 notify_permission_trampoline::<F> as *const (),
652 )),
653 Box_::into_raw(f),
654 )
655 }
656 }
657
658 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
659 #[doc(alias = "text-lock")]
660 pub fn connect_text_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
661 unsafe extern "C" fn notify_text_lock_trampoline<F: Fn(&LockButton) + 'static>(
662 this: *mut ffi::GtkLockButton,
663 _param_spec: glib::ffi::gpointer,
664 f: glib::ffi::gpointer,
665 ) {
666 unsafe {
667 let f: &F = &*(f as *const F);
668 f(&from_glib_borrow(this))
669 }
670 }
671 unsafe {
672 let f: Box_<F> = Box_::new(f);
673 connect_raw(
674 self.as_ptr() as *mut _,
675 c"notify::text-lock".as_ptr(),
676 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
677 notify_text_lock_trampoline::<F> as *const (),
678 )),
679 Box_::into_raw(f),
680 )
681 }
682 }
683
684 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
685 #[doc(alias = "text-unlock")]
686 pub fn connect_text_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
687 unsafe extern "C" fn notify_text_unlock_trampoline<F: Fn(&LockButton) + 'static>(
688 this: *mut ffi::GtkLockButton,
689 _param_spec: glib::ffi::gpointer,
690 f: glib::ffi::gpointer,
691 ) {
692 unsafe {
693 let f: &F = &*(f as *const F);
694 f(&from_glib_borrow(this))
695 }
696 }
697 unsafe {
698 let f: Box_<F> = Box_::new(f);
699 connect_raw(
700 self.as_ptr() as *mut _,
701 c"notify::text-unlock".as_ptr(),
702 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
703 notify_text_unlock_trampoline::<F> as *const (),
704 )),
705 Box_::into_raw(f),
706 )
707 }
708 }
709
710 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
711 #[doc(alias = "tooltip-lock")]
712 pub fn connect_tooltip_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
713 unsafe extern "C" fn notify_tooltip_lock_trampoline<F: Fn(&LockButton) + 'static>(
714 this: *mut ffi::GtkLockButton,
715 _param_spec: glib::ffi::gpointer,
716 f: glib::ffi::gpointer,
717 ) {
718 unsafe {
719 let f: &F = &*(f as *const F);
720 f(&from_glib_borrow(this))
721 }
722 }
723 unsafe {
724 let f: Box_<F> = Box_::new(f);
725 connect_raw(
726 self.as_ptr() as *mut _,
727 c"notify::tooltip-lock".as_ptr(),
728 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
729 notify_tooltip_lock_trampoline::<F> as *const (),
730 )),
731 Box_::into_raw(f),
732 )
733 }
734 }
735
736 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
737 #[doc(alias = "tooltip-not-authorized")]
738 pub fn connect_tooltip_not_authorized_notify<F: Fn(&Self) + 'static>(
739 &self,
740 f: F,
741 ) -> SignalHandlerId {
742 unsafe extern "C" fn notify_tooltip_not_authorized_trampoline<
743 F: Fn(&LockButton) + 'static,
744 >(
745 this: *mut ffi::GtkLockButton,
746 _param_spec: glib::ffi::gpointer,
747 f: glib::ffi::gpointer,
748 ) {
749 unsafe {
750 let f: &F = &*(f as *const F);
751 f(&from_glib_borrow(this))
752 }
753 }
754 unsafe {
755 let f: Box_<F> = Box_::new(f);
756 connect_raw(
757 self.as_ptr() as *mut _,
758 c"notify::tooltip-not-authorized".as_ptr(),
759 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
760 notify_tooltip_not_authorized_trampoline::<F> as *const (),
761 )),
762 Box_::into_raw(f),
763 )
764 }
765 }
766
767 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
768 #[doc(alias = "tooltip-unlock")]
769 pub fn connect_tooltip_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
770 unsafe extern "C" fn notify_tooltip_unlock_trampoline<F: Fn(&LockButton) + 'static>(
771 this: *mut ffi::GtkLockButton,
772 _param_spec: glib::ffi::gpointer,
773 f: glib::ffi::gpointer,
774 ) {
775 unsafe {
776 let f: &F = &*(f as *const F);
777 f(&from_glib_borrow(this))
778 }
779 }
780 unsafe {
781 let f: Box_<F> = Box_::new(f);
782 connect_raw(
783 self.as_ptr() as *mut _,
784 c"notify::tooltip-unlock".as_ptr(),
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}