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