1#![allow(deprecated)]
5
6use crate::{
7 ffi, Accessible, AccessibleRole, Actionable, Align, Buildable, Button, ConstraintTarget,
8 LayoutManager, Overflow, Widget,
9};
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "GtkLockButton")]
19 pub struct LockButton(Object<ffi::GtkLockButton>) @extends Button, Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable;
20
21 match fn {
22 type_ => || ffi::gtk_lock_button_get_type(),
23 }
24}
25
26impl LockButton {
27 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
28 #[allow(deprecated)]
29 #[doc(alias = "gtk_lock_button_new")]
30 pub fn new(permission: Option<&impl IsA<gio::Permission>>) -> LockButton {
31 assert_initialized_main_thread!();
32 unsafe {
33 Widget::from_glib_none(ffi::gtk_lock_button_new(
34 permission.map(|p| p.as_ref()).to_glib_none().0,
35 ))
36 .unsafe_cast()
37 }
38 }
39
40 pub fn builder() -> LockButtonBuilder {
45 LockButtonBuilder::new()
46 }
47
48 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
49 #[allow(deprecated)]
50 #[doc(alias = "gtk_lock_button_get_permission")]
51 #[doc(alias = "get_permission")]
52 pub fn permission(&self) -> Option<gio::Permission> {
53 unsafe { from_glib_none(ffi::gtk_lock_button_get_permission(self.to_glib_none().0)) }
54 }
55
56 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
57 #[allow(deprecated)]
58 #[doc(alias = "gtk_lock_button_set_permission")]
59 #[doc(alias = "permission")]
60 pub fn set_permission(&self, permission: Option<&impl IsA<gio::Permission>>) {
61 unsafe {
62 ffi::gtk_lock_button_set_permission(
63 self.to_glib_none().0,
64 permission.map(|p| p.as_ref()).to_glib_none().0,
65 );
66 }
67 }
68
69 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
70 #[doc(alias = "text-lock")]
71 pub fn text_lock(&self) -> Option<glib::GString> {
72 ObjectExt::property(self, "text-lock")
73 }
74
75 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
76 #[doc(alias = "text-lock")]
77 pub fn set_text_lock(&self, text_lock: Option<&str>) {
78 ObjectExt::set_property(self, "text-lock", text_lock)
79 }
80
81 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
82 #[doc(alias = "text-unlock")]
83 pub fn text_unlock(&self) -> Option<glib::GString> {
84 ObjectExt::property(self, "text-unlock")
85 }
86
87 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
88 #[doc(alias = "text-unlock")]
89 pub fn set_text_unlock(&self, text_unlock: Option<&str>) {
90 ObjectExt::set_property(self, "text-unlock", text_unlock)
91 }
92
93 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
94 #[doc(alias = "tooltip-lock")]
95 pub fn tooltip_lock(&self) -> Option<glib::GString> {
96 ObjectExt::property(self, "tooltip-lock")
97 }
98
99 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
100 #[doc(alias = "tooltip-lock")]
101 pub fn set_tooltip_lock(&self, tooltip_lock: Option<&str>) {
102 ObjectExt::set_property(self, "tooltip-lock", tooltip_lock)
103 }
104
105 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
106 #[doc(alias = "tooltip-not-authorized")]
107 pub fn tooltip_not_authorized(&self) -> Option<glib::GString> {
108 ObjectExt::property(self, "tooltip-not-authorized")
109 }
110
111 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
112 #[doc(alias = "tooltip-not-authorized")]
113 pub fn set_tooltip_not_authorized(&self, tooltip_not_authorized: Option<&str>) {
114 ObjectExt::set_property(self, "tooltip-not-authorized", tooltip_not_authorized)
115 }
116
117 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
118 #[doc(alias = "tooltip-unlock")]
119 pub fn tooltip_unlock(&self) -> Option<glib::GString> {
120 ObjectExt::property(self, "tooltip-unlock")
121 }
122
123 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
124 #[doc(alias = "tooltip-unlock")]
125 pub fn set_tooltip_unlock(&self, tooltip_unlock: Option<&str>) {
126 ObjectExt::set_property(self, "tooltip-unlock", tooltip_unlock)
127 }
128
129 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
130 #[doc(alias = "permission")]
131 pub fn connect_permission_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
132 unsafe extern "C" fn notify_permission_trampoline<F: Fn(&LockButton) + 'static>(
133 this: *mut ffi::GtkLockButton,
134 _param_spec: glib::ffi::gpointer,
135 f: glib::ffi::gpointer,
136 ) {
137 let f: &F = &*(f as *const F);
138 f(&from_glib_borrow(this))
139 }
140 unsafe {
141 let f: Box_<F> = Box_::new(f);
142 connect_raw(
143 self.as_ptr() as *mut _,
144 c"notify::permission".as_ptr() as *const _,
145 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
146 notify_permission_trampoline::<F> as *const (),
147 )),
148 Box_::into_raw(f),
149 )
150 }
151 }
152
153 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
154 #[doc(alias = "text-lock")]
155 pub fn connect_text_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
156 unsafe extern "C" fn notify_text_lock_trampoline<F: Fn(&LockButton) + 'static>(
157 this: *mut ffi::GtkLockButton,
158 _param_spec: glib::ffi::gpointer,
159 f: glib::ffi::gpointer,
160 ) {
161 let f: &F = &*(f as *const F);
162 f(&from_glib_borrow(this))
163 }
164 unsafe {
165 let f: Box_<F> = Box_::new(f);
166 connect_raw(
167 self.as_ptr() as *mut _,
168 c"notify::text-lock".as_ptr() as *const _,
169 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
170 notify_text_lock_trampoline::<F> as *const (),
171 )),
172 Box_::into_raw(f),
173 )
174 }
175 }
176
177 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
178 #[doc(alias = "text-unlock")]
179 pub fn connect_text_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
180 unsafe extern "C" fn notify_text_unlock_trampoline<F: Fn(&LockButton) + 'static>(
181 this: *mut ffi::GtkLockButton,
182 _param_spec: glib::ffi::gpointer,
183 f: glib::ffi::gpointer,
184 ) {
185 let f: &F = &*(f as *const F);
186 f(&from_glib_borrow(this))
187 }
188 unsafe {
189 let f: Box_<F> = Box_::new(f);
190 connect_raw(
191 self.as_ptr() as *mut _,
192 c"notify::text-unlock".as_ptr() as *const _,
193 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194 notify_text_unlock_trampoline::<F> as *const (),
195 )),
196 Box_::into_raw(f),
197 )
198 }
199 }
200
201 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
202 #[doc(alias = "tooltip-lock")]
203 pub fn connect_tooltip_lock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
204 unsafe extern "C" fn notify_tooltip_lock_trampoline<F: Fn(&LockButton) + 'static>(
205 this: *mut ffi::GtkLockButton,
206 _param_spec: glib::ffi::gpointer,
207 f: glib::ffi::gpointer,
208 ) {
209 let f: &F = &*(f as *const F);
210 f(&from_glib_borrow(this))
211 }
212 unsafe {
213 let f: Box_<F> = Box_::new(f);
214 connect_raw(
215 self.as_ptr() as *mut _,
216 c"notify::tooltip-lock".as_ptr() as *const _,
217 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218 notify_tooltip_lock_trampoline::<F> as *const (),
219 )),
220 Box_::into_raw(f),
221 )
222 }
223 }
224
225 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
226 #[doc(alias = "tooltip-not-authorized")]
227 pub fn connect_tooltip_not_authorized_notify<F: Fn(&Self) + 'static>(
228 &self,
229 f: F,
230 ) -> SignalHandlerId {
231 unsafe extern "C" fn notify_tooltip_not_authorized_trampoline<
232 F: Fn(&LockButton) + 'static,
233 >(
234 this: *mut ffi::GtkLockButton,
235 _param_spec: glib::ffi::gpointer,
236 f: glib::ffi::gpointer,
237 ) {
238 let f: &F = &*(f as *const F);
239 f(&from_glib_borrow(this))
240 }
241 unsafe {
242 let f: Box_<F> = Box_::new(f);
243 connect_raw(
244 self.as_ptr() as *mut _,
245 c"notify::tooltip-not-authorized".as_ptr() as *const _,
246 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247 notify_tooltip_not_authorized_trampoline::<F> as *const (),
248 )),
249 Box_::into_raw(f),
250 )
251 }
252 }
253
254 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
255 #[doc(alias = "tooltip-unlock")]
256 pub fn connect_tooltip_unlock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
257 unsafe extern "C" fn notify_tooltip_unlock_trampoline<F: Fn(&LockButton) + 'static>(
258 this: *mut ffi::GtkLockButton,
259 _param_spec: glib::ffi::gpointer,
260 f: glib::ffi::gpointer,
261 ) {
262 let f: &F = &*(f as *const F);
263 f(&from_glib_borrow(this))
264 }
265 unsafe {
266 let f: Box_<F> = Box_::new(f);
267 connect_raw(
268 self.as_ptr() as *mut _,
269 c"notify::tooltip-unlock".as_ptr() as *const _,
270 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
271 notify_tooltip_unlock_trampoline::<F> as *const (),
272 )),
273 Box_::into_raw(f),
274 )
275 }
276 }
277}
278
279impl Default for LockButton {
280 fn default() -> Self {
281 glib::object::Object::new::<Self>()
282 }
283}
284
285#[must_use = "The builder must be built to be used"]
290pub struct LockButtonBuilder {
291 builder: glib::object::ObjectBuilder<'static, LockButton>,
292}
293
294impl LockButtonBuilder {
295 fn new() -> Self {
296 Self {
297 builder: glib::object::Object::builder(),
298 }
299 }
300
301 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
302 pub fn permission(self, permission: &impl IsA<gio::Permission>) -> Self {
303 Self {
304 builder: self
305 .builder
306 .property("permission", permission.clone().upcast()),
307 }
308 }
309
310 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
311 pub fn text_lock(self, text_lock: impl Into<glib::GString>) -> Self {
312 Self {
313 builder: self.builder.property("text-lock", text_lock.into()),
314 }
315 }
316
317 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
318 pub fn text_unlock(self, text_unlock: impl Into<glib::GString>) -> Self {
319 Self {
320 builder: self.builder.property("text-unlock", text_unlock.into()),
321 }
322 }
323
324 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
325 pub fn tooltip_lock(self, tooltip_lock: impl Into<glib::GString>) -> Self {
326 Self {
327 builder: self.builder.property("tooltip-lock", tooltip_lock.into()),
328 }
329 }
330
331 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
332 pub fn tooltip_not_authorized(self, tooltip_not_authorized: impl Into<glib::GString>) -> Self {
333 Self {
334 builder: self
335 .builder
336 .property("tooltip-not-authorized", tooltip_not_authorized.into()),
337 }
338 }
339
340 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
341 pub fn tooltip_unlock(self, tooltip_unlock: impl Into<glib::GString>) -> Self {
342 Self {
343 builder: self
344 .builder
345 .property("tooltip-unlock", tooltip_unlock.into()),
346 }
347 }
348
349 #[cfg(feature = "v4_12")]
350 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
351 pub fn can_shrink(self, can_shrink: bool) -> Self {
352 Self {
353 builder: self.builder.property("can-shrink", can_shrink),
354 }
355 }
356
357 pub fn child(self, child: &impl IsA<Widget>) -> Self {
358 Self {
359 builder: self.builder.property("child", child.clone().upcast()),
360 }
361 }
362
363 pub fn has_frame(self, has_frame: bool) -> Self {
364 Self {
365 builder: self.builder.property("has-frame", has_frame),
366 }
367 }
368
369 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
370 Self {
371 builder: self.builder.property("icon-name", icon_name.into()),
372 }
373 }
374
375 pub fn label(self, label: impl Into<glib::GString>) -> Self {
376 Self {
377 builder: self.builder.property("label", label.into()),
378 }
379 }
380
381 pub fn use_underline(self, use_underline: bool) -> Self {
382 Self {
383 builder: self.builder.property("use-underline", use_underline),
384 }
385 }
386
387 pub fn can_focus(self, can_focus: bool) -> Self {
388 Self {
389 builder: self.builder.property("can-focus", can_focus),
390 }
391 }
392
393 pub fn can_target(self, can_target: bool) -> Self {
394 Self {
395 builder: self.builder.property("can-target", can_target),
396 }
397 }
398
399 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
400 Self {
401 builder: self.builder.property("css-classes", css_classes.into()),
402 }
403 }
404
405 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
406 Self {
407 builder: self.builder.property("css-name", css_name.into()),
408 }
409 }
410
411 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
412 Self {
413 builder: self.builder.property("cursor", cursor.clone()),
414 }
415 }
416
417 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
418 Self {
419 builder: self.builder.property("focus-on-click", focus_on_click),
420 }
421 }
422
423 pub fn focusable(self, focusable: bool) -> Self {
424 Self {
425 builder: self.builder.property("focusable", focusable),
426 }
427 }
428
429 pub fn halign(self, halign: Align) -> Self {
430 Self {
431 builder: self.builder.property("halign", halign),
432 }
433 }
434
435 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
436 Self {
437 builder: self.builder.property("has-tooltip", has_tooltip),
438 }
439 }
440
441 pub fn height_request(self, height_request: i32) -> Self {
442 Self {
443 builder: self.builder.property("height-request", height_request),
444 }
445 }
446
447 pub fn hexpand(self, hexpand: bool) -> Self {
448 Self {
449 builder: self.builder.property("hexpand", hexpand),
450 }
451 }
452
453 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
454 Self {
455 builder: self.builder.property("hexpand-set", hexpand_set),
456 }
457 }
458
459 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
460 Self {
461 builder: self
462 .builder
463 .property("layout-manager", layout_manager.clone().upcast()),
464 }
465 }
466
467 #[cfg(feature = "v4_18")]
468 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
469 pub fn limit_events(self, limit_events: bool) -> Self {
470 Self {
471 builder: self.builder.property("limit-events", limit_events),
472 }
473 }
474
475 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
476 Self {
477 builder: self.builder.property("margin-bottom", margin_bottom),
478 }
479 }
480
481 pub fn margin_end(self, margin_end: i32) -> Self {
482 Self {
483 builder: self.builder.property("margin-end", margin_end),
484 }
485 }
486
487 pub fn margin_start(self, margin_start: i32) -> Self {
488 Self {
489 builder: self.builder.property("margin-start", margin_start),
490 }
491 }
492
493 pub fn margin_top(self, margin_top: i32) -> Self {
494 Self {
495 builder: self.builder.property("margin-top", margin_top),
496 }
497 }
498
499 pub fn name(self, name: impl Into<glib::GString>) -> Self {
500 Self {
501 builder: self.builder.property("name", name.into()),
502 }
503 }
504
505 pub fn opacity(self, opacity: f64) -> Self {
506 Self {
507 builder: self.builder.property("opacity", opacity),
508 }
509 }
510
511 pub fn overflow(self, overflow: Overflow) -> Self {
512 Self {
513 builder: self.builder.property("overflow", overflow),
514 }
515 }
516
517 pub fn receives_default(self, receives_default: bool) -> Self {
518 Self {
519 builder: self.builder.property("receives-default", receives_default),
520 }
521 }
522
523 pub fn sensitive(self, sensitive: bool) -> Self {
524 Self {
525 builder: self.builder.property("sensitive", sensitive),
526 }
527 }
528
529 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
530 Self {
531 builder: self
532 .builder
533 .property("tooltip-markup", tooltip_markup.into()),
534 }
535 }
536
537 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
538 Self {
539 builder: self.builder.property("tooltip-text", tooltip_text.into()),
540 }
541 }
542
543 pub fn valign(self, valign: Align) -> Self {
544 Self {
545 builder: self.builder.property("valign", valign),
546 }
547 }
548
549 pub fn vexpand(self, vexpand: bool) -> Self {
550 Self {
551 builder: self.builder.property("vexpand", vexpand),
552 }
553 }
554
555 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
556 Self {
557 builder: self.builder.property("vexpand-set", vexpand_set),
558 }
559 }
560
561 pub fn visible(self, visible: bool) -> Self {
562 Self {
563 builder: self.builder.property("visible", visible),
564 }
565 }
566
567 pub fn width_request(self, width_request: i32) -> Self {
568 Self {
569 builder: self.builder.property("width-request", width_request),
570 }
571 }
572
573 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
574 Self {
575 builder: self.builder.property("accessible-role", accessible_role),
576 }
577 }
578
579 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
580 Self {
581 builder: self.builder.property("action-name", action_name.into()),
582 }
583 }
584
585 pub fn action_target(self, action_target: &glib::Variant) -> Self {
586 Self {
587 builder: self
588 .builder
589 .property("action-target", action_target.clone()),
590 }
591 }
592
593 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
596 pub fn build(self) -> LockButton {
597 assert_initialized_main_thread!();
598 self.builder.build()
599 }
600}