1use crate::{
6 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, FontDialog, FontLevel,
7 LayoutManager, Overflow, Widget,
8};
9#[cfg(feature = "v4_14")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
11use glib::object::ObjectType as _;
12use glib::{
13 prelude::*,
14 signal::{connect_raw, SignalHandlerId},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 #[doc(alias = "GtkFontDialogButton")]
21 pub struct FontDialogButton(Object<ffi::GtkFontDialogButton, ffi::GtkFontDialogButtonClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
22
23 match fn {
24 type_ => || ffi::gtk_font_dialog_button_get_type(),
25 }
26}
27
28impl FontDialogButton {
29 #[doc(alias = "gtk_font_dialog_button_new")]
30 pub fn new(dialog: Option<FontDialog>) -> FontDialogButton {
31 assert_initialized_main_thread!();
32 unsafe {
33 Widget::from_glib_none(ffi::gtk_font_dialog_button_new(dialog.into_glib_ptr()))
34 .unsafe_cast()
35 }
36 }
37
38 pub fn builder() -> FontDialogButtonBuilder {
43 FontDialogButtonBuilder::new()
44 }
45
46 #[doc(alias = "gtk_font_dialog_button_get_dialog")]
47 #[doc(alias = "get_dialog")]
48 pub fn dialog(&self) -> Option<FontDialog> {
49 unsafe {
50 from_glib_none(ffi::gtk_font_dialog_button_get_dialog(
51 self.to_glib_none().0,
52 ))
53 }
54 }
55
56 #[doc(alias = "gtk_font_dialog_button_get_font_desc")]
57 #[doc(alias = "get_font_desc")]
58 #[doc(alias = "font-desc")]
59 pub fn font_desc(&self) -> Option<pango::FontDescription> {
60 unsafe {
61 from_glib_none(ffi::gtk_font_dialog_button_get_font_desc(
62 self.to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "gtk_font_dialog_button_get_font_features")]
68 #[doc(alias = "get_font_features")]
69 #[doc(alias = "font-features")]
70 pub fn font_features(&self) -> Option<glib::GString> {
71 unsafe {
72 from_glib_none(ffi::gtk_font_dialog_button_get_font_features(
73 self.to_glib_none().0,
74 ))
75 }
76 }
77
78 #[doc(alias = "gtk_font_dialog_button_get_language")]
79 #[doc(alias = "get_language")]
80 pub fn language(&self) -> Option<pango::Language> {
81 unsafe {
82 from_glib_full(ffi::gtk_font_dialog_button_get_language(
83 self.to_glib_none().0,
84 ))
85 }
86 }
87
88 #[doc(alias = "gtk_font_dialog_button_get_level")]
89 #[doc(alias = "get_level")]
90 pub fn level(&self) -> FontLevel {
91 unsafe { from_glib(ffi::gtk_font_dialog_button_get_level(self.to_glib_none().0)) }
92 }
93
94 #[doc(alias = "gtk_font_dialog_button_get_use_font")]
95 #[doc(alias = "get_use_font")]
96 #[doc(alias = "use-font")]
97 pub fn uses_font(&self) -> bool {
98 unsafe {
99 from_glib(ffi::gtk_font_dialog_button_get_use_font(
100 self.to_glib_none().0,
101 ))
102 }
103 }
104
105 #[doc(alias = "gtk_font_dialog_button_get_use_size")]
106 #[doc(alias = "get_use_size")]
107 #[doc(alias = "use-size")]
108 pub fn uses_size(&self) -> bool {
109 unsafe {
110 from_glib(ffi::gtk_font_dialog_button_get_use_size(
111 self.to_glib_none().0,
112 ))
113 }
114 }
115
116 #[doc(alias = "gtk_font_dialog_button_set_dialog")]
117 #[doc(alias = "dialog")]
118 pub fn set_dialog(&self, dialog: &FontDialog) {
119 unsafe {
120 ffi::gtk_font_dialog_button_set_dialog(self.to_glib_none().0, dialog.to_glib_none().0);
121 }
122 }
123
124 #[doc(alias = "gtk_font_dialog_button_set_font_desc")]
125 #[doc(alias = "font-desc")]
126 pub fn set_font_desc(&self, font_desc: &pango::FontDescription) {
127 unsafe {
128 ffi::gtk_font_dialog_button_set_font_desc(
129 self.to_glib_none().0,
130 font_desc.to_glib_none().0,
131 );
132 }
133 }
134
135 #[doc(alias = "gtk_font_dialog_button_set_font_features")]
136 #[doc(alias = "font-features")]
137 pub fn set_font_features(&self, font_features: Option<&str>) {
138 unsafe {
139 ffi::gtk_font_dialog_button_set_font_features(
140 self.to_glib_none().0,
141 font_features.to_glib_none().0,
142 );
143 }
144 }
145
146 #[doc(alias = "gtk_font_dialog_button_set_language")]
147 #[doc(alias = "language")]
148 pub fn set_language(&self, language: Option<&pango::Language>) {
149 unsafe {
150 ffi::gtk_font_dialog_button_set_language(
151 self.to_glib_none().0,
152 mut_override(language.to_glib_none().0),
153 );
154 }
155 }
156
157 #[doc(alias = "gtk_font_dialog_button_set_level")]
158 #[doc(alias = "level")]
159 pub fn set_level(&self, level: FontLevel) {
160 unsafe {
161 ffi::gtk_font_dialog_button_set_level(self.to_glib_none().0, level.into_glib());
162 }
163 }
164
165 #[doc(alias = "gtk_font_dialog_button_set_use_font")]
166 #[doc(alias = "use-font")]
167 pub fn set_use_font(&self, use_font: bool) {
168 unsafe {
169 ffi::gtk_font_dialog_button_set_use_font(self.to_glib_none().0, use_font.into_glib());
170 }
171 }
172
173 #[doc(alias = "gtk_font_dialog_button_set_use_size")]
174 #[doc(alias = "use-size")]
175 pub fn set_use_size(&self, use_size: bool) {
176 unsafe {
177 ffi::gtk_font_dialog_button_set_use_size(self.to_glib_none().0, use_size.into_glib());
178 }
179 }
180
181 #[cfg(not(feature = "v4_10"))]
182 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
183 pub fn level(&self) -> FontLevel {
184 ObjectExt::property(self, "level")
185 }
186
187 #[cfg(not(feature = "v4_10"))]
188 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
189 pub fn set_level(&self, level: FontLevel) {
190 ObjectExt::set_property(self, "level", level)
191 }
192
193 #[cfg(not(feature = "v4_10"))]
194 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
195 #[doc(alias = "use-font")]
196 pub fn uses_font(&self) -> bool {
197 ObjectExt::property(self, "use-font")
198 }
199
200 #[cfg(not(feature = "v4_10"))]
201 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
202 #[doc(alias = "use-font")]
203 pub fn set_use_font(&self, use_font: bool) {
204 ObjectExt::set_property(self, "use-font", use_font)
205 }
206
207 #[cfg(not(feature = "v4_10"))]
208 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
209 #[doc(alias = "use-size")]
210 pub fn uses_size(&self) -> bool {
211 ObjectExt::property(self, "use-size")
212 }
213
214 #[cfg(not(feature = "v4_10"))]
215 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_10"))))]
216 #[doc(alias = "use-size")]
217 pub fn set_use_size(&self, use_size: bool) {
218 ObjectExt::set_property(self, "use-size", use_size)
219 }
220
221 #[cfg(feature = "v4_14")]
222 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
223 #[doc(alias = "activate")]
224 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
225 unsafe extern "C" fn activate_trampoline<F: Fn(&FontDialogButton) + 'static>(
226 this: *mut ffi::GtkFontDialogButton,
227 f: glib::ffi::gpointer,
228 ) {
229 let f: &F = &*(f as *const F);
230 f(&from_glib_borrow(this))
231 }
232 unsafe {
233 let f: Box_<F> = Box_::new(f);
234 connect_raw(
235 self.as_ptr() as *mut _,
236 c"activate".as_ptr() as *const _,
237 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
238 activate_trampoline::<F> as *const (),
239 )),
240 Box_::into_raw(f),
241 )
242 }
243 }
244
245 #[cfg(feature = "v4_14")]
246 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
247 pub fn emit_activate(&self) {
248 self.emit_by_name::<()>("activate", &[]);
249 }
250
251 #[cfg(feature = "v4_10")]
252 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
253 #[doc(alias = "dialog")]
254 pub fn connect_dialog_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
255 unsafe extern "C" fn notify_dialog_trampoline<F: Fn(&FontDialogButton) + 'static>(
256 this: *mut ffi::GtkFontDialogButton,
257 _param_spec: glib::ffi::gpointer,
258 f: glib::ffi::gpointer,
259 ) {
260 let f: &F = &*(f as *const F);
261 f(&from_glib_borrow(this))
262 }
263 unsafe {
264 let f: Box_<F> = Box_::new(f);
265 connect_raw(
266 self.as_ptr() as *mut _,
267 c"notify::dialog".as_ptr() as *const _,
268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
269 notify_dialog_trampoline::<F> as *const (),
270 )),
271 Box_::into_raw(f),
272 )
273 }
274 }
275
276 #[cfg(feature = "v4_10")]
277 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
278 #[doc(alias = "font-desc")]
279 pub fn connect_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
280 unsafe extern "C" fn notify_font_desc_trampoline<F: Fn(&FontDialogButton) + 'static>(
281 this: *mut ffi::GtkFontDialogButton,
282 _param_spec: glib::ffi::gpointer,
283 f: glib::ffi::gpointer,
284 ) {
285 let f: &F = &*(f as *const F);
286 f(&from_glib_borrow(this))
287 }
288 unsafe {
289 let f: Box_<F> = Box_::new(f);
290 connect_raw(
291 self.as_ptr() as *mut _,
292 c"notify::font-desc".as_ptr() as *const _,
293 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
294 notify_font_desc_trampoline::<F> as *const (),
295 )),
296 Box_::into_raw(f),
297 )
298 }
299 }
300
301 #[cfg(feature = "v4_10")]
302 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
303 #[doc(alias = "font-features")]
304 pub fn connect_font_features_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
305 unsafe extern "C" fn notify_font_features_trampoline<F: Fn(&FontDialogButton) + 'static>(
306 this: *mut ffi::GtkFontDialogButton,
307 _param_spec: glib::ffi::gpointer,
308 f: glib::ffi::gpointer,
309 ) {
310 let f: &F = &*(f as *const F);
311 f(&from_glib_borrow(this))
312 }
313 unsafe {
314 let f: Box_<F> = Box_::new(f);
315 connect_raw(
316 self.as_ptr() as *mut _,
317 c"notify::font-features".as_ptr() as *const _,
318 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
319 notify_font_features_trampoline::<F> as *const (),
320 )),
321 Box_::into_raw(f),
322 )
323 }
324 }
325
326 #[cfg(feature = "v4_10")]
327 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
328 #[doc(alias = "language")]
329 pub fn connect_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
330 unsafe extern "C" fn notify_language_trampoline<F: Fn(&FontDialogButton) + 'static>(
331 this: *mut ffi::GtkFontDialogButton,
332 _param_spec: glib::ffi::gpointer,
333 f: glib::ffi::gpointer,
334 ) {
335 let f: &F = &*(f as *const F);
336 f(&from_glib_borrow(this))
337 }
338 unsafe {
339 let f: Box_<F> = Box_::new(f);
340 connect_raw(
341 self.as_ptr() as *mut _,
342 c"notify::language".as_ptr() as *const _,
343 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
344 notify_language_trampoline::<F> as *const (),
345 )),
346 Box_::into_raw(f),
347 )
348 }
349 }
350
351 #[doc(alias = "level")]
352 pub fn connect_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
353 unsafe extern "C" fn notify_level_trampoline<F: Fn(&FontDialogButton) + 'static>(
354 this: *mut ffi::GtkFontDialogButton,
355 _param_spec: glib::ffi::gpointer,
356 f: glib::ffi::gpointer,
357 ) {
358 let f: &F = &*(f as *const F);
359 f(&from_glib_borrow(this))
360 }
361 unsafe {
362 let f: Box_<F> = Box_::new(f);
363 connect_raw(
364 self.as_ptr() as *mut _,
365 c"notify::level".as_ptr() as *const _,
366 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
367 notify_level_trampoline::<F> as *const (),
368 )),
369 Box_::into_raw(f),
370 )
371 }
372 }
373
374 #[doc(alias = "use-font")]
375 pub fn connect_use_font_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
376 unsafe extern "C" fn notify_use_font_trampoline<F: Fn(&FontDialogButton) + 'static>(
377 this: *mut ffi::GtkFontDialogButton,
378 _param_spec: glib::ffi::gpointer,
379 f: glib::ffi::gpointer,
380 ) {
381 let f: &F = &*(f as *const F);
382 f(&from_glib_borrow(this))
383 }
384 unsafe {
385 let f: Box_<F> = Box_::new(f);
386 connect_raw(
387 self.as_ptr() as *mut _,
388 c"notify::use-font".as_ptr() as *const _,
389 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
390 notify_use_font_trampoline::<F> as *const (),
391 )),
392 Box_::into_raw(f),
393 )
394 }
395 }
396
397 #[doc(alias = "use-size")]
398 pub fn connect_use_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
399 unsafe extern "C" fn notify_use_size_trampoline<F: Fn(&FontDialogButton) + 'static>(
400 this: *mut ffi::GtkFontDialogButton,
401 _param_spec: glib::ffi::gpointer,
402 f: glib::ffi::gpointer,
403 ) {
404 let f: &F = &*(f as *const F);
405 f(&from_glib_borrow(this))
406 }
407 unsafe {
408 let f: Box_<F> = Box_::new(f);
409 connect_raw(
410 self.as_ptr() as *mut _,
411 c"notify::use-size".as_ptr() as *const _,
412 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413 notify_use_size_trampoline::<F> as *const (),
414 )),
415 Box_::into_raw(f),
416 )
417 }
418 }
419}
420
421#[cfg(feature = "v4_10")]
422#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
423impl Default for FontDialogButton {
424 fn default() -> Self {
425 glib::object::Object::new::<Self>()
426 }
427}
428
429#[must_use = "The builder must be built to be used"]
434pub struct FontDialogButtonBuilder {
435 builder: glib::object::ObjectBuilder<'static, FontDialogButton>,
436}
437
438impl FontDialogButtonBuilder {
439 fn new() -> Self {
440 Self {
441 builder: glib::object::Object::builder(),
442 }
443 }
444
445 #[cfg(feature = "v4_10")]
446 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
447 pub fn dialog(self, dialog: &FontDialog) -> Self {
448 Self {
449 builder: self.builder.property("dialog", dialog.clone()),
450 }
451 }
452
453 #[cfg(feature = "v4_10")]
454 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
455 pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
456 Self {
457 builder: self.builder.property("font-desc", font_desc),
458 }
459 }
460
461 #[cfg(feature = "v4_10")]
462 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
463 pub fn font_features(self, font_features: impl Into<glib::GString>) -> Self {
464 Self {
465 builder: self.builder.property("font-features", font_features.into()),
466 }
467 }
468
469 #[cfg(feature = "v4_10")]
470 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
471 pub fn language(self, language: &pango::Language) -> Self {
472 Self {
473 builder: self.builder.property("language", language),
474 }
475 }
476
477 pub fn level(self, level: FontLevel) -> Self {
478 Self {
479 builder: self.builder.property("level", level),
480 }
481 }
482
483 pub fn use_font(self, use_font: bool) -> Self {
484 Self {
485 builder: self.builder.property("use-font", use_font),
486 }
487 }
488
489 pub fn use_size(self, use_size: bool) -> Self {
490 Self {
491 builder: self.builder.property("use-size", use_size),
492 }
493 }
494
495 pub fn can_focus(self, can_focus: bool) -> Self {
496 Self {
497 builder: self.builder.property("can-focus", can_focus),
498 }
499 }
500
501 pub fn can_target(self, can_target: bool) -> Self {
502 Self {
503 builder: self.builder.property("can-target", can_target),
504 }
505 }
506
507 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
508 Self {
509 builder: self.builder.property("css-classes", css_classes.into()),
510 }
511 }
512
513 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
514 Self {
515 builder: self.builder.property("css-name", css_name.into()),
516 }
517 }
518
519 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
520 Self {
521 builder: self.builder.property("cursor", cursor.clone()),
522 }
523 }
524
525 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
526 Self {
527 builder: self.builder.property("focus-on-click", focus_on_click),
528 }
529 }
530
531 pub fn focusable(self, focusable: bool) -> Self {
532 Self {
533 builder: self.builder.property("focusable", focusable),
534 }
535 }
536
537 pub fn halign(self, halign: Align) -> Self {
538 Self {
539 builder: self.builder.property("halign", halign),
540 }
541 }
542
543 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
544 Self {
545 builder: self.builder.property("has-tooltip", has_tooltip),
546 }
547 }
548
549 pub fn height_request(self, height_request: i32) -> Self {
550 Self {
551 builder: self.builder.property("height-request", height_request),
552 }
553 }
554
555 pub fn hexpand(self, hexpand: bool) -> Self {
556 Self {
557 builder: self.builder.property("hexpand", hexpand),
558 }
559 }
560
561 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
562 Self {
563 builder: self.builder.property("hexpand-set", hexpand_set),
564 }
565 }
566
567 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
568 Self {
569 builder: self
570 .builder
571 .property("layout-manager", layout_manager.clone().upcast()),
572 }
573 }
574
575 #[cfg(feature = "v4_18")]
576 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
577 pub fn limit_events(self, limit_events: bool) -> Self {
578 Self {
579 builder: self.builder.property("limit-events", limit_events),
580 }
581 }
582
583 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
584 Self {
585 builder: self.builder.property("margin-bottom", margin_bottom),
586 }
587 }
588
589 pub fn margin_end(self, margin_end: i32) -> Self {
590 Self {
591 builder: self.builder.property("margin-end", margin_end),
592 }
593 }
594
595 pub fn margin_start(self, margin_start: i32) -> Self {
596 Self {
597 builder: self.builder.property("margin-start", margin_start),
598 }
599 }
600
601 pub fn margin_top(self, margin_top: i32) -> Self {
602 Self {
603 builder: self.builder.property("margin-top", margin_top),
604 }
605 }
606
607 pub fn name(self, name: impl Into<glib::GString>) -> Self {
608 Self {
609 builder: self.builder.property("name", name.into()),
610 }
611 }
612
613 pub fn opacity(self, opacity: f64) -> Self {
614 Self {
615 builder: self.builder.property("opacity", opacity),
616 }
617 }
618
619 pub fn overflow(self, overflow: Overflow) -> Self {
620 Self {
621 builder: self.builder.property("overflow", overflow),
622 }
623 }
624
625 pub fn receives_default(self, receives_default: bool) -> Self {
626 Self {
627 builder: self.builder.property("receives-default", receives_default),
628 }
629 }
630
631 pub fn sensitive(self, sensitive: bool) -> Self {
632 Self {
633 builder: self.builder.property("sensitive", sensitive),
634 }
635 }
636
637 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
638 Self {
639 builder: self
640 .builder
641 .property("tooltip-markup", tooltip_markup.into()),
642 }
643 }
644
645 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
646 Self {
647 builder: self.builder.property("tooltip-text", tooltip_text.into()),
648 }
649 }
650
651 pub fn valign(self, valign: Align) -> Self {
652 Self {
653 builder: self.builder.property("valign", valign),
654 }
655 }
656
657 pub fn vexpand(self, vexpand: bool) -> Self {
658 Self {
659 builder: self.builder.property("vexpand", vexpand),
660 }
661 }
662
663 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
664 Self {
665 builder: self.builder.property("vexpand-set", vexpand_set),
666 }
667 }
668
669 pub fn visible(self, visible: bool) -> Self {
670 Self {
671 builder: self.builder.property("visible", visible),
672 }
673 }
674
675 pub fn width_request(self, width_request: i32) -> Self {
676 Self {
677 builder: self.builder.property("width-request", width_request),
678 }
679 }
680
681 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
682 Self {
683 builder: self.builder.property("accessible-role", accessible_role),
684 }
685 }
686
687 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
690 pub fn build(self) -> FontDialogButton {
691 assert_initialized_main_thread!();
692 self.builder.build()
693 }
694}