1use gdk;
6use gdk_pixbuf;
7use glib::object::Cast;
8use glib::object::IsA;
9use glib::translate::*;
10use glib::StaticType;
11use glib::ToValue;
12use gtk_sys;
13use std::fmt;
14use Align;
15use Application;
16use Bin;
17use Buildable;
18use Container;
19use Dialog;
20use FontChooser;
21use ResizeMode;
22use Widget;
23use Window;
24use WindowPosition;
25use WindowType;
26
27glib_wrapper! {
28 pub struct FontChooserDialog(Object<gtk_sys::GtkFontChooserDialog, gtk_sys::GtkFontChooserDialogClass, FontChooserDialogClass>) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, FontChooser;
29
30 match fn {
31 get_type => || gtk_sys::gtk_font_chooser_dialog_get_type(),
32 }
33}
34
35impl FontChooserDialog {
36 pub fn new<P: IsA<Window>>(title: Option<&str>, parent: Option<&P>) -> FontChooserDialog {
37 assert_initialized_main_thread!();
38 unsafe {
39 Widget::from_glib_none(gtk_sys::gtk_font_chooser_dialog_new(
40 title.to_glib_none().0,
41 parent.map(|p| p.as_ref()).to_glib_none().0,
42 ))
43 .unsafe_cast()
44 }
45 }
46}
47
48pub struct FontChooserDialogBuilder {
49 use_header_bar: Option<i32>,
50 accept_focus: Option<bool>,
51 application: Option<Application>,
52 attached_to: Option<Widget>,
53 decorated: Option<bool>,
54 default_height: Option<i32>,
55 default_width: Option<i32>,
56 deletable: Option<bool>,
57 destroy_with_parent: Option<bool>,
58 focus_on_map: Option<bool>,
59 focus_visible: Option<bool>,
60 gravity: Option<gdk::Gravity>,
61 hide_titlebar_when_maximized: Option<bool>,
62 icon: Option<gdk_pixbuf::Pixbuf>,
63 icon_name: Option<String>,
64 mnemonics_visible: Option<bool>,
65 modal: Option<bool>,
66 resizable: Option<bool>,
67 role: Option<String>,
68 screen: Option<gdk::Screen>,
69 skip_pager_hint: Option<bool>,
70 skip_taskbar_hint: Option<bool>,
71 startup_id: Option<String>,
72 title: Option<String>,
73 transient_for: Option<Window>,
74 type_: Option<WindowType>,
75 type_hint: Option<gdk::WindowTypeHint>,
76 urgency_hint: Option<bool>,
77 window_position: Option<WindowPosition>,
78 border_width: Option<u32>,
79 child: Option<Widget>,
80 resize_mode: Option<ResizeMode>,
81 app_paintable: Option<bool>,
82 can_default: Option<bool>,
83 can_focus: Option<bool>,
84 events: Option<gdk::EventMask>,
85 expand: Option<bool>,
86 #[cfg(any(feature = "v3_20", feature = "dox"))]
87 focus_on_click: Option<bool>,
88 halign: Option<Align>,
89 has_default: Option<bool>,
90 has_focus: Option<bool>,
91 has_tooltip: Option<bool>,
92 height_request: Option<i32>,
93 hexpand: Option<bool>,
94 hexpand_set: Option<bool>,
95 is_focus: Option<bool>,
96 margin: Option<i32>,
97 margin_bottom: Option<i32>,
98 margin_end: Option<i32>,
99 margin_start: Option<i32>,
100 margin_top: Option<i32>,
101 name: Option<String>,
102 no_show_all: Option<bool>,
103 opacity: Option<f64>,
104 parent: Option<Container>,
105 receives_default: Option<bool>,
106 sensitive: Option<bool>,
107 tooltip_markup: Option<String>,
109 tooltip_text: Option<String>,
110 valign: Option<Align>,
111 vexpand: Option<bool>,
112 vexpand_set: Option<bool>,
113 visible: Option<bool>,
114 width_request: Option<i32>,
115}
116
117impl FontChooserDialogBuilder {
118 pub fn new() -> Self {
119 Self {
120 use_header_bar: None,
121 accept_focus: None,
122 application: None,
123 attached_to: None,
124 decorated: None,
125 default_height: None,
126 default_width: None,
127 deletable: None,
128 destroy_with_parent: None,
129 focus_on_map: None,
130 focus_visible: None,
131 gravity: None,
132 hide_titlebar_when_maximized: None,
133 icon: None,
134 icon_name: None,
135 mnemonics_visible: None,
136 modal: None,
137 resizable: None,
138 role: None,
139 screen: None,
140 skip_pager_hint: None,
141 skip_taskbar_hint: None,
142 startup_id: None,
143 title: None,
144 transient_for: None,
145 type_: None,
146 type_hint: None,
147 urgency_hint: None,
148 window_position: None,
149 border_width: None,
150 child: None,
151 resize_mode: None,
152 app_paintable: None,
153 can_default: None,
154 can_focus: None,
155 events: None,
156 expand: None,
157 #[cfg(any(feature = "v3_20", feature = "dox"))]
158 focus_on_click: None,
159 halign: None,
160 has_default: None,
161 has_focus: None,
162 has_tooltip: None,
163 height_request: None,
164 hexpand: None,
165 hexpand_set: None,
166 is_focus: None,
167 margin: None,
168 margin_bottom: None,
169 margin_end: None,
170 margin_start: None,
171 margin_top: None,
172 name: None,
173 no_show_all: None,
174 opacity: None,
175 parent: None,
176 receives_default: None,
177 sensitive: None,
178 tooltip_markup: None,
179 tooltip_text: None,
180 valign: None,
181 vexpand: None,
182 vexpand_set: None,
183 visible: None,
184 width_request: None,
185 }
186 }
187
188 pub fn build(self) -> FontChooserDialog {
189 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
190 if let Some(ref use_header_bar) = self.use_header_bar {
191 properties.push(("use-header-bar", use_header_bar));
192 }
193 if let Some(ref accept_focus) = self.accept_focus {
194 properties.push(("accept-focus", accept_focus));
195 }
196 if let Some(ref application) = self.application {
197 properties.push(("application", application));
198 }
199 if let Some(ref attached_to) = self.attached_to {
200 properties.push(("attached-to", attached_to));
201 }
202 if let Some(ref decorated) = self.decorated {
203 properties.push(("decorated", decorated));
204 }
205 if let Some(ref default_height) = self.default_height {
206 properties.push(("default-height", default_height));
207 }
208 if let Some(ref default_width) = self.default_width {
209 properties.push(("default-width", default_width));
210 }
211 if let Some(ref deletable) = self.deletable {
212 properties.push(("deletable", deletable));
213 }
214 if let Some(ref destroy_with_parent) = self.destroy_with_parent {
215 properties.push(("destroy-with-parent", destroy_with_parent));
216 }
217 if let Some(ref focus_on_map) = self.focus_on_map {
218 properties.push(("focus-on-map", focus_on_map));
219 }
220 if let Some(ref focus_visible) = self.focus_visible {
221 properties.push(("focus-visible", focus_visible));
222 }
223 if let Some(ref gravity) = self.gravity {
224 properties.push(("gravity", gravity));
225 }
226 if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized {
227 properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized));
228 }
229 if let Some(ref icon) = self.icon {
230 properties.push(("icon", icon));
231 }
232 if let Some(ref icon_name) = self.icon_name {
233 properties.push(("icon-name", icon_name));
234 }
235 if let Some(ref mnemonics_visible) = self.mnemonics_visible {
236 properties.push(("mnemonics-visible", mnemonics_visible));
237 }
238 if let Some(ref modal) = self.modal {
239 properties.push(("modal", modal));
240 }
241 if let Some(ref resizable) = self.resizable {
242 properties.push(("resizable", resizable));
243 }
244 if let Some(ref role) = self.role {
245 properties.push(("role", role));
246 }
247 if let Some(ref screen) = self.screen {
248 properties.push(("screen", screen));
249 }
250 if let Some(ref skip_pager_hint) = self.skip_pager_hint {
251 properties.push(("skip-pager-hint", skip_pager_hint));
252 }
253 if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint {
254 properties.push(("skip-taskbar-hint", skip_taskbar_hint));
255 }
256 if let Some(ref startup_id) = self.startup_id {
257 properties.push(("startup-id", startup_id));
258 }
259 if let Some(ref title) = self.title {
260 properties.push(("title", title));
261 }
262 if let Some(ref transient_for) = self.transient_for {
263 properties.push(("transient-for", transient_for));
264 }
265 if let Some(ref type_) = self.type_ {
266 properties.push(("type", type_));
267 }
268 if let Some(ref type_hint) = self.type_hint {
269 properties.push(("type-hint", type_hint));
270 }
271 if let Some(ref urgency_hint) = self.urgency_hint {
272 properties.push(("urgency-hint", urgency_hint));
273 }
274 if let Some(ref window_position) = self.window_position {
275 properties.push(("window-position", window_position));
276 }
277 if let Some(ref border_width) = self.border_width {
278 properties.push(("border-width", border_width));
279 }
280 if let Some(ref child) = self.child {
281 properties.push(("child", child));
282 }
283 if let Some(ref resize_mode) = self.resize_mode {
284 properties.push(("resize-mode", resize_mode));
285 }
286 if let Some(ref app_paintable) = self.app_paintable {
287 properties.push(("app-paintable", app_paintable));
288 }
289 if let Some(ref can_default) = self.can_default {
290 properties.push(("can-default", can_default));
291 }
292 if let Some(ref can_focus) = self.can_focus {
293 properties.push(("can-focus", can_focus));
294 }
295 if let Some(ref events) = self.events {
296 properties.push(("events", events));
297 }
298 if let Some(ref expand) = self.expand {
299 properties.push(("expand", expand));
300 }
301 #[cfg(any(feature = "v3_20", feature = "dox"))]
302 {
303 if let Some(ref focus_on_click) = self.focus_on_click {
304 properties.push(("focus-on-click", focus_on_click));
305 }
306 }
307 if let Some(ref halign) = self.halign {
308 properties.push(("halign", halign));
309 }
310 if let Some(ref has_default) = self.has_default {
311 properties.push(("has-default", has_default));
312 }
313 if let Some(ref has_focus) = self.has_focus {
314 properties.push(("has-focus", has_focus));
315 }
316 if let Some(ref has_tooltip) = self.has_tooltip {
317 properties.push(("has-tooltip", has_tooltip));
318 }
319 if let Some(ref height_request) = self.height_request {
320 properties.push(("height-request", height_request));
321 }
322 if let Some(ref hexpand) = self.hexpand {
323 properties.push(("hexpand", hexpand));
324 }
325 if let Some(ref hexpand_set) = self.hexpand_set {
326 properties.push(("hexpand-set", hexpand_set));
327 }
328 if let Some(ref is_focus) = self.is_focus {
329 properties.push(("is-focus", is_focus));
330 }
331 if let Some(ref margin) = self.margin {
332 properties.push(("margin", margin));
333 }
334 if let Some(ref margin_bottom) = self.margin_bottom {
335 properties.push(("margin-bottom", margin_bottom));
336 }
337 if let Some(ref margin_end) = self.margin_end {
338 properties.push(("margin-end", margin_end));
339 }
340 if let Some(ref margin_start) = self.margin_start {
341 properties.push(("margin-start", margin_start));
342 }
343 if let Some(ref margin_top) = self.margin_top {
344 properties.push(("margin-top", margin_top));
345 }
346 if let Some(ref name) = self.name {
347 properties.push(("name", name));
348 }
349 if let Some(ref no_show_all) = self.no_show_all {
350 properties.push(("no-show-all", no_show_all));
351 }
352 if let Some(ref opacity) = self.opacity {
353 properties.push(("opacity", opacity));
354 }
355 if let Some(ref parent) = self.parent {
356 properties.push(("parent", parent));
357 }
358 if let Some(ref receives_default) = self.receives_default {
359 properties.push(("receives-default", receives_default));
360 }
361 if let Some(ref sensitive) = self.sensitive {
362 properties.push(("sensitive", sensitive));
363 }
364 if let Some(ref tooltip_markup) = self.tooltip_markup {
365 properties.push(("tooltip-markup", tooltip_markup));
366 }
367 if let Some(ref tooltip_text) = self.tooltip_text {
368 properties.push(("tooltip-text", tooltip_text));
369 }
370 if let Some(ref valign) = self.valign {
371 properties.push(("valign", valign));
372 }
373 if let Some(ref vexpand) = self.vexpand {
374 properties.push(("vexpand", vexpand));
375 }
376 if let Some(ref vexpand_set) = self.vexpand_set {
377 properties.push(("vexpand-set", vexpand_set));
378 }
379 if let Some(ref visible) = self.visible {
380 properties.push(("visible", visible));
381 }
382 if let Some(ref width_request) = self.width_request {
383 properties.push(("width-request", width_request));
384 }
385 glib::Object::new(FontChooserDialog::static_type(), &properties)
386 .expect("object new")
387 .downcast()
388 .expect("downcast")
389 }
390
391 pub fn use_header_bar(mut self, use_header_bar: i32) -> Self {
392 self.use_header_bar = Some(use_header_bar);
393 self
394 }
395
396 pub fn accept_focus(mut self, accept_focus: bool) -> Self {
397 self.accept_focus = Some(accept_focus);
398 self
399 }
400
401 pub fn application(mut self, application: &Application) -> Self {
402 self.application = Some(application.clone());
403 self
404 }
405
406 pub fn attached_to(mut self, attached_to: &Widget) -> Self {
407 self.attached_to = Some(attached_to.clone());
408 self
409 }
410
411 pub fn decorated(mut self, decorated: bool) -> Self {
412 self.decorated = Some(decorated);
413 self
414 }
415
416 pub fn default_height(mut self, default_height: i32) -> Self {
417 self.default_height = Some(default_height);
418 self
419 }
420
421 pub fn default_width(mut self, default_width: i32) -> Self {
422 self.default_width = Some(default_width);
423 self
424 }
425
426 pub fn deletable(mut self, deletable: bool) -> Self {
427 self.deletable = Some(deletable);
428 self
429 }
430
431 pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self {
432 self.destroy_with_parent = Some(destroy_with_parent);
433 self
434 }
435
436 pub fn focus_on_map(mut self, focus_on_map: bool) -> Self {
437 self.focus_on_map = Some(focus_on_map);
438 self
439 }
440
441 pub fn focus_visible(mut self, focus_visible: bool) -> Self {
442 self.focus_visible = Some(focus_visible);
443 self
444 }
445
446 pub fn gravity(mut self, gravity: gdk::Gravity) -> Self {
447 self.gravity = Some(gravity);
448 self
449 }
450
451 pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self {
452 self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized);
453 self
454 }
455
456 pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self {
457 self.icon = Some(icon.clone());
458 self
459 }
460
461 pub fn icon_name(mut self, icon_name: &str) -> Self {
462 self.icon_name = Some(icon_name.to_string());
463 self
464 }
465
466 pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self {
467 self.mnemonics_visible = Some(mnemonics_visible);
468 self
469 }
470
471 pub fn modal(mut self, modal: bool) -> Self {
472 self.modal = Some(modal);
473 self
474 }
475
476 pub fn resizable(mut self, resizable: bool) -> Self {
477 self.resizable = Some(resizable);
478 self
479 }
480
481 pub fn role(mut self, role: &str) -> Self {
482 self.role = Some(role.to_string());
483 self
484 }
485
486 pub fn screen(mut self, screen: &gdk::Screen) -> Self {
487 self.screen = Some(screen.clone());
488 self
489 }
490
491 pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self {
492 self.skip_pager_hint = Some(skip_pager_hint);
493 self
494 }
495
496 pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self {
497 self.skip_taskbar_hint = Some(skip_taskbar_hint);
498 self
499 }
500
501 pub fn startup_id(mut self, startup_id: &str) -> Self {
502 self.startup_id = Some(startup_id.to_string());
503 self
504 }
505
506 pub fn title(mut self, title: &str) -> Self {
507 self.title = Some(title.to_string());
508 self
509 }
510
511 pub fn transient_for(mut self, transient_for: &Window) -> Self {
512 self.transient_for = Some(transient_for.clone());
513 self
514 }
515
516 pub fn type_(mut self, type_: WindowType) -> Self {
517 self.type_ = Some(type_);
518 self
519 }
520
521 pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self {
522 self.type_hint = Some(type_hint);
523 self
524 }
525
526 pub fn urgency_hint(mut self, urgency_hint: bool) -> Self {
527 self.urgency_hint = Some(urgency_hint);
528 self
529 }
530
531 pub fn window_position(mut self, window_position: WindowPosition) -> Self {
532 self.window_position = Some(window_position);
533 self
534 }
535
536 pub fn border_width(mut self, border_width: u32) -> Self {
537 self.border_width = Some(border_width);
538 self
539 }
540
541 pub fn child(mut self, child: &Widget) -> Self {
542 self.child = Some(child.clone());
543 self
544 }
545
546 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
547 self.resize_mode = Some(resize_mode);
548 self
549 }
550
551 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
552 self.app_paintable = Some(app_paintable);
553 self
554 }
555
556 pub fn can_default(mut self, can_default: bool) -> Self {
557 self.can_default = Some(can_default);
558 self
559 }
560
561 pub fn can_focus(mut self, can_focus: bool) -> Self {
562 self.can_focus = Some(can_focus);
563 self
564 }
565
566 pub fn events(mut self, events: gdk::EventMask) -> Self {
567 self.events = Some(events);
568 self
569 }
570
571 pub fn expand(mut self, expand: bool) -> Self {
572 self.expand = Some(expand);
573 self
574 }
575
576 #[cfg(any(feature = "v3_20", feature = "dox"))]
577 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
578 self.focus_on_click = Some(focus_on_click);
579 self
580 }
581
582 pub fn halign(mut self, halign: Align) -> Self {
583 self.halign = Some(halign);
584 self
585 }
586
587 pub fn has_default(mut self, has_default: bool) -> Self {
588 self.has_default = Some(has_default);
589 self
590 }
591
592 pub fn has_focus(mut self, has_focus: bool) -> Self {
593 self.has_focus = Some(has_focus);
594 self
595 }
596
597 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
598 self.has_tooltip = Some(has_tooltip);
599 self
600 }
601
602 pub fn height_request(mut self, height_request: i32) -> Self {
603 self.height_request = Some(height_request);
604 self
605 }
606
607 pub fn hexpand(mut self, hexpand: bool) -> Self {
608 self.hexpand = Some(hexpand);
609 self
610 }
611
612 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
613 self.hexpand_set = Some(hexpand_set);
614 self
615 }
616
617 pub fn is_focus(mut self, is_focus: bool) -> Self {
618 self.is_focus = Some(is_focus);
619 self
620 }
621
622 pub fn margin(mut self, margin: i32) -> Self {
623 self.margin = Some(margin);
624 self
625 }
626
627 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
628 self.margin_bottom = Some(margin_bottom);
629 self
630 }
631
632 pub fn margin_end(mut self, margin_end: i32) -> Self {
633 self.margin_end = Some(margin_end);
634 self
635 }
636
637 pub fn margin_start(mut self, margin_start: i32) -> Self {
638 self.margin_start = Some(margin_start);
639 self
640 }
641
642 pub fn margin_top(mut self, margin_top: i32) -> Self {
643 self.margin_top = Some(margin_top);
644 self
645 }
646
647 pub fn name(mut self, name: &str) -> Self {
648 self.name = Some(name.to_string());
649 self
650 }
651
652 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
653 self.no_show_all = Some(no_show_all);
654 self
655 }
656
657 pub fn opacity(mut self, opacity: f64) -> Self {
658 self.opacity = Some(opacity);
659 self
660 }
661
662 pub fn parent(mut self, parent: &Container) -> Self {
663 self.parent = Some(parent.clone());
664 self
665 }
666
667 pub fn receives_default(mut self, receives_default: bool) -> Self {
668 self.receives_default = Some(receives_default);
669 self
670 }
671
672 pub fn sensitive(mut self, sensitive: bool) -> Self {
673 self.sensitive = Some(sensitive);
674 self
675 }
676
677 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
678 self.tooltip_markup = Some(tooltip_markup.to_string());
679 self
680 }
681
682 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
683 self.tooltip_text = Some(tooltip_text.to_string());
684 self
685 }
686
687 pub fn valign(mut self, valign: Align) -> Self {
688 self.valign = Some(valign);
689 self
690 }
691
692 pub fn vexpand(mut self, vexpand: bool) -> Self {
693 self.vexpand = Some(vexpand);
694 self
695 }
696
697 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
698 self.vexpand_set = Some(vexpand_set);
699 self
700 }
701
702 pub fn visible(mut self, visible: bool) -> Self {
703 self.visible = Some(visible);
704 self
705 }
706
707 pub fn width_request(mut self, width_request: i32) -> Self {
708 self.width_request = Some(width_request);
709 self
710 }
711}
712
713pub const NONE_FONT_CHOOSER_DIALOG: Option<&FontChooserDialog> = None;
714
715impl fmt::Display for FontChooserDialog {
716 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
717 write!(f, "FontChooserDialog")
718 }
719}