1use gdk;
6use gdk_pixbuf;
7use glib;
8use glib::object::Cast;
9use glib::object::IsA;
10use glib::object::ObjectExt;
11use glib::signal::connect_raw;
12use glib::signal::SignalHandlerId;
13use glib::translate::*;
14use glib::StaticType;
15use glib::ToValue;
16use glib::Value;
17use glib_sys;
18use gobject_sys;
19use gtk_sys;
20use std::boxed::Box as Box_;
21use std::fmt;
22use std::mem::transmute;
23use Align;
24use Application;
25use Bin;
26use Box;
27use Buildable;
28use Container;
29use ResizeMode;
30use ResponseType;
31use Widget;
32use Window;
33use WindowPosition;
34use WindowType;
35
36glib_wrapper! {
37 pub struct Dialog(Object<gtk_sys::GtkDialog, gtk_sys::GtkDialogClass, DialogClass>) @extends Window, Bin, Container, Widget, @implements Buildable;
38
39 match fn {
40 get_type => || gtk_sys::gtk_dialog_get_type(),
41 }
42}
43
44impl Dialog {
45 pub fn new() -> Dialog {
46 assert_initialized_main_thread!();
47 unsafe { Widget::from_glib_none(gtk_sys::gtk_dialog_new()).unsafe_cast() }
48 }
49
50 }
54
55impl Default for Dialog {
56 fn default() -> Self {
57 Self::new()
58 }
59}
60
61pub struct DialogBuilder {
62 use_header_bar: Option<i32>,
63 accept_focus: Option<bool>,
64 application: Option<Application>,
65 attached_to: Option<Widget>,
66 decorated: Option<bool>,
67 default_height: Option<i32>,
68 default_width: Option<i32>,
69 deletable: Option<bool>,
70 destroy_with_parent: Option<bool>,
71 focus_on_map: Option<bool>,
72 focus_visible: Option<bool>,
73 gravity: Option<gdk::Gravity>,
74 hide_titlebar_when_maximized: Option<bool>,
75 icon: Option<gdk_pixbuf::Pixbuf>,
76 icon_name: Option<String>,
77 mnemonics_visible: Option<bool>,
78 modal: Option<bool>,
79 resizable: Option<bool>,
80 role: Option<String>,
81 screen: Option<gdk::Screen>,
82 skip_pager_hint: Option<bool>,
83 skip_taskbar_hint: Option<bool>,
84 startup_id: Option<String>,
85 title: Option<String>,
86 transient_for: Option<Window>,
87 type_: Option<WindowType>,
88 type_hint: Option<gdk::WindowTypeHint>,
89 urgency_hint: Option<bool>,
90 window_position: Option<WindowPosition>,
91 border_width: Option<u32>,
92 child: Option<Widget>,
93 resize_mode: Option<ResizeMode>,
94 app_paintable: Option<bool>,
95 can_default: Option<bool>,
96 can_focus: Option<bool>,
97 events: Option<gdk::EventMask>,
98 expand: Option<bool>,
99 #[cfg(any(feature = "v3_20", feature = "dox"))]
100 focus_on_click: Option<bool>,
101 halign: Option<Align>,
102 has_default: Option<bool>,
103 has_focus: Option<bool>,
104 has_tooltip: Option<bool>,
105 height_request: Option<i32>,
106 hexpand: Option<bool>,
107 hexpand_set: Option<bool>,
108 is_focus: Option<bool>,
109 margin: Option<i32>,
110 margin_bottom: Option<i32>,
111 margin_end: Option<i32>,
112 margin_start: Option<i32>,
113 margin_top: Option<i32>,
114 name: Option<String>,
115 no_show_all: Option<bool>,
116 opacity: Option<f64>,
117 parent: Option<Container>,
118 receives_default: Option<bool>,
119 sensitive: Option<bool>,
120 tooltip_markup: Option<String>,
122 tooltip_text: Option<String>,
123 valign: Option<Align>,
124 vexpand: Option<bool>,
125 vexpand_set: Option<bool>,
126 visible: Option<bool>,
127 width_request: Option<i32>,
128}
129
130impl DialogBuilder {
131 pub fn new() -> Self {
132 Self {
133 use_header_bar: None,
134 accept_focus: None,
135 application: None,
136 attached_to: None,
137 decorated: None,
138 default_height: None,
139 default_width: None,
140 deletable: None,
141 destroy_with_parent: None,
142 focus_on_map: None,
143 focus_visible: None,
144 gravity: None,
145 hide_titlebar_when_maximized: None,
146 icon: None,
147 icon_name: None,
148 mnemonics_visible: None,
149 modal: None,
150 resizable: None,
151 role: None,
152 screen: None,
153 skip_pager_hint: None,
154 skip_taskbar_hint: None,
155 startup_id: None,
156 title: None,
157 transient_for: None,
158 type_: None,
159 type_hint: None,
160 urgency_hint: None,
161 window_position: None,
162 border_width: None,
163 child: None,
164 resize_mode: None,
165 app_paintable: None,
166 can_default: None,
167 can_focus: None,
168 events: None,
169 expand: None,
170 #[cfg(any(feature = "v3_20", feature = "dox"))]
171 focus_on_click: None,
172 halign: None,
173 has_default: None,
174 has_focus: None,
175 has_tooltip: None,
176 height_request: None,
177 hexpand: None,
178 hexpand_set: None,
179 is_focus: None,
180 margin: None,
181 margin_bottom: None,
182 margin_end: None,
183 margin_start: None,
184 margin_top: None,
185 name: None,
186 no_show_all: None,
187 opacity: None,
188 parent: None,
189 receives_default: None,
190 sensitive: None,
191 tooltip_markup: None,
192 tooltip_text: None,
193 valign: None,
194 vexpand: None,
195 vexpand_set: None,
196 visible: None,
197 width_request: None,
198 }
199 }
200
201 pub fn build(self) -> Dialog {
202 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
203 if let Some(ref use_header_bar) = self.use_header_bar {
204 properties.push(("use-header-bar", use_header_bar));
205 }
206 if let Some(ref accept_focus) = self.accept_focus {
207 properties.push(("accept-focus", accept_focus));
208 }
209 if let Some(ref application) = self.application {
210 properties.push(("application", application));
211 }
212 if let Some(ref attached_to) = self.attached_to {
213 properties.push(("attached-to", attached_to));
214 }
215 if let Some(ref decorated) = self.decorated {
216 properties.push(("decorated", decorated));
217 }
218 if let Some(ref default_height) = self.default_height {
219 properties.push(("default-height", default_height));
220 }
221 if let Some(ref default_width) = self.default_width {
222 properties.push(("default-width", default_width));
223 }
224 if let Some(ref deletable) = self.deletable {
225 properties.push(("deletable", deletable));
226 }
227 if let Some(ref destroy_with_parent) = self.destroy_with_parent {
228 properties.push(("destroy-with-parent", destroy_with_parent));
229 }
230 if let Some(ref focus_on_map) = self.focus_on_map {
231 properties.push(("focus-on-map", focus_on_map));
232 }
233 if let Some(ref focus_visible) = self.focus_visible {
234 properties.push(("focus-visible", focus_visible));
235 }
236 if let Some(ref gravity) = self.gravity {
237 properties.push(("gravity", gravity));
238 }
239 if let Some(ref hide_titlebar_when_maximized) = self.hide_titlebar_when_maximized {
240 properties.push(("hide-titlebar-when-maximized", hide_titlebar_when_maximized));
241 }
242 if let Some(ref icon) = self.icon {
243 properties.push(("icon", icon));
244 }
245 if let Some(ref icon_name) = self.icon_name {
246 properties.push(("icon-name", icon_name));
247 }
248 if let Some(ref mnemonics_visible) = self.mnemonics_visible {
249 properties.push(("mnemonics-visible", mnemonics_visible));
250 }
251 if let Some(ref modal) = self.modal {
252 properties.push(("modal", modal));
253 }
254 if let Some(ref resizable) = self.resizable {
255 properties.push(("resizable", resizable));
256 }
257 if let Some(ref role) = self.role {
258 properties.push(("role", role));
259 }
260 if let Some(ref screen) = self.screen {
261 properties.push(("screen", screen));
262 }
263 if let Some(ref skip_pager_hint) = self.skip_pager_hint {
264 properties.push(("skip-pager-hint", skip_pager_hint));
265 }
266 if let Some(ref skip_taskbar_hint) = self.skip_taskbar_hint {
267 properties.push(("skip-taskbar-hint", skip_taskbar_hint));
268 }
269 if let Some(ref startup_id) = self.startup_id {
270 properties.push(("startup-id", startup_id));
271 }
272 if let Some(ref title) = self.title {
273 properties.push(("title", title));
274 }
275 if let Some(ref transient_for) = self.transient_for {
276 properties.push(("transient-for", transient_for));
277 }
278 if let Some(ref type_) = self.type_ {
279 properties.push(("type", type_));
280 }
281 if let Some(ref type_hint) = self.type_hint {
282 properties.push(("type-hint", type_hint));
283 }
284 if let Some(ref urgency_hint) = self.urgency_hint {
285 properties.push(("urgency-hint", urgency_hint));
286 }
287 if let Some(ref window_position) = self.window_position {
288 properties.push(("window-position", window_position));
289 }
290 if let Some(ref border_width) = self.border_width {
291 properties.push(("border-width", border_width));
292 }
293 if let Some(ref child) = self.child {
294 properties.push(("child", child));
295 }
296 if let Some(ref resize_mode) = self.resize_mode {
297 properties.push(("resize-mode", resize_mode));
298 }
299 if let Some(ref app_paintable) = self.app_paintable {
300 properties.push(("app-paintable", app_paintable));
301 }
302 if let Some(ref can_default) = self.can_default {
303 properties.push(("can-default", can_default));
304 }
305 if let Some(ref can_focus) = self.can_focus {
306 properties.push(("can-focus", can_focus));
307 }
308 if let Some(ref events) = self.events {
309 properties.push(("events", events));
310 }
311 if let Some(ref expand) = self.expand {
312 properties.push(("expand", expand));
313 }
314 #[cfg(any(feature = "v3_20", feature = "dox"))]
315 {
316 if let Some(ref focus_on_click) = self.focus_on_click {
317 properties.push(("focus-on-click", focus_on_click));
318 }
319 }
320 if let Some(ref halign) = self.halign {
321 properties.push(("halign", halign));
322 }
323 if let Some(ref has_default) = self.has_default {
324 properties.push(("has-default", has_default));
325 }
326 if let Some(ref has_focus) = self.has_focus {
327 properties.push(("has-focus", has_focus));
328 }
329 if let Some(ref has_tooltip) = self.has_tooltip {
330 properties.push(("has-tooltip", has_tooltip));
331 }
332 if let Some(ref height_request) = self.height_request {
333 properties.push(("height-request", height_request));
334 }
335 if let Some(ref hexpand) = self.hexpand {
336 properties.push(("hexpand", hexpand));
337 }
338 if let Some(ref hexpand_set) = self.hexpand_set {
339 properties.push(("hexpand-set", hexpand_set));
340 }
341 if let Some(ref is_focus) = self.is_focus {
342 properties.push(("is-focus", is_focus));
343 }
344 if let Some(ref margin) = self.margin {
345 properties.push(("margin", margin));
346 }
347 if let Some(ref margin_bottom) = self.margin_bottom {
348 properties.push(("margin-bottom", margin_bottom));
349 }
350 if let Some(ref margin_end) = self.margin_end {
351 properties.push(("margin-end", margin_end));
352 }
353 if let Some(ref margin_start) = self.margin_start {
354 properties.push(("margin-start", margin_start));
355 }
356 if let Some(ref margin_top) = self.margin_top {
357 properties.push(("margin-top", margin_top));
358 }
359 if let Some(ref name) = self.name {
360 properties.push(("name", name));
361 }
362 if let Some(ref no_show_all) = self.no_show_all {
363 properties.push(("no-show-all", no_show_all));
364 }
365 if let Some(ref opacity) = self.opacity {
366 properties.push(("opacity", opacity));
367 }
368 if let Some(ref parent) = self.parent {
369 properties.push(("parent", parent));
370 }
371 if let Some(ref receives_default) = self.receives_default {
372 properties.push(("receives-default", receives_default));
373 }
374 if let Some(ref sensitive) = self.sensitive {
375 properties.push(("sensitive", sensitive));
376 }
377 if let Some(ref tooltip_markup) = self.tooltip_markup {
378 properties.push(("tooltip-markup", tooltip_markup));
379 }
380 if let Some(ref tooltip_text) = self.tooltip_text {
381 properties.push(("tooltip-text", tooltip_text));
382 }
383 if let Some(ref valign) = self.valign {
384 properties.push(("valign", valign));
385 }
386 if let Some(ref vexpand) = self.vexpand {
387 properties.push(("vexpand", vexpand));
388 }
389 if let Some(ref vexpand_set) = self.vexpand_set {
390 properties.push(("vexpand-set", vexpand_set));
391 }
392 if let Some(ref visible) = self.visible {
393 properties.push(("visible", visible));
394 }
395 if let Some(ref width_request) = self.width_request {
396 properties.push(("width-request", width_request));
397 }
398 glib::Object::new(Dialog::static_type(), &properties)
399 .expect("object new")
400 .downcast()
401 .expect("downcast")
402 }
403
404 pub fn use_header_bar(mut self, use_header_bar: i32) -> Self {
405 self.use_header_bar = Some(use_header_bar);
406 self
407 }
408
409 pub fn accept_focus(mut self, accept_focus: bool) -> Self {
410 self.accept_focus = Some(accept_focus);
411 self
412 }
413
414 pub fn application(mut self, application: &Application) -> Self {
415 self.application = Some(application.clone());
416 self
417 }
418
419 pub fn attached_to(mut self, attached_to: &Widget) -> Self {
420 self.attached_to = Some(attached_to.clone());
421 self
422 }
423
424 pub fn decorated(mut self, decorated: bool) -> Self {
425 self.decorated = Some(decorated);
426 self
427 }
428
429 pub fn default_height(mut self, default_height: i32) -> Self {
430 self.default_height = Some(default_height);
431 self
432 }
433
434 pub fn default_width(mut self, default_width: i32) -> Self {
435 self.default_width = Some(default_width);
436 self
437 }
438
439 pub fn deletable(mut self, deletable: bool) -> Self {
440 self.deletable = Some(deletable);
441 self
442 }
443
444 pub fn destroy_with_parent(mut self, destroy_with_parent: bool) -> Self {
445 self.destroy_with_parent = Some(destroy_with_parent);
446 self
447 }
448
449 pub fn focus_on_map(mut self, focus_on_map: bool) -> Self {
450 self.focus_on_map = Some(focus_on_map);
451 self
452 }
453
454 pub fn focus_visible(mut self, focus_visible: bool) -> Self {
455 self.focus_visible = Some(focus_visible);
456 self
457 }
458
459 pub fn gravity(mut self, gravity: gdk::Gravity) -> Self {
460 self.gravity = Some(gravity);
461 self
462 }
463
464 pub fn hide_titlebar_when_maximized(mut self, hide_titlebar_when_maximized: bool) -> Self {
465 self.hide_titlebar_when_maximized = Some(hide_titlebar_when_maximized);
466 self
467 }
468
469 pub fn icon(mut self, icon: &gdk_pixbuf::Pixbuf) -> Self {
470 self.icon = Some(icon.clone());
471 self
472 }
473
474 pub fn icon_name(mut self, icon_name: &str) -> Self {
475 self.icon_name = Some(icon_name.to_string());
476 self
477 }
478
479 pub fn mnemonics_visible(mut self, mnemonics_visible: bool) -> Self {
480 self.mnemonics_visible = Some(mnemonics_visible);
481 self
482 }
483
484 pub fn modal(mut self, modal: bool) -> Self {
485 self.modal = Some(modal);
486 self
487 }
488
489 pub fn resizable(mut self, resizable: bool) -> Self {
490 self.resizable = Some(resizable);
491 self
492 }
493
494 pub fn role(mut self, role: &str) -> Self {
495 self.role = Some(role.to_string());
496 self
497 }
498
499 pub fn screen(mut self, screen: &gdk::Screen) -> Self {
500 self.screen = Some(screen.clone());
501 self
502 }
503
504 pub fn skip_pager_hint(mut self, skip_pager_hint: bool) -> Self {
505 self.skip_pager_hint = Some(skip_pager_hint);
506 self
507 }
508
509 pub fn skip_taskbar_hint(mut self, skip_taskbar_hint: bool) -> Self {
510 self.skip_taskbar_hint = Some(skip_taskbar_hint);
511 self
512 }
513
514 pub fn startup_id(mut self, startup_id: &str) -> Self {
515 self.startup_id = Some(startup_id.to_string());
516 self
517 }
518
519 pub fn title(mut self, title: &str) -> Self {
520 self.title = Some(title.to_string());
521 self
522 }
523
524 pub fn transient_for(mut self, transient_for: &Window) -> Self {
525 self.transient_for = Some(transient_for.clone());
526 self
527 }
528
529 pub fn type_(mut self, type_: WindowType) -> Self {
530 self.type_ = Some(type_);
531 self
532 }
533
534 pub fn type_hint(mut self, type_hint: gdk::WindowTypeHint) -> Self {
535 self.type_hint = Some(type_hint);
536 self
537 }
538
539 pub fn urgency_hint(mut self, urgency_hint: bool) -> Self {
540 self.urgency_hint = Some(urgency_hint);
541 self
542 }
543
544 pub fn window_position(mut self, window_position: WindowPosition) -> Self {
545 self.window_position = Some(window_position);
546 self
547 }
548
549 pub fn border_width(mut self, border_width: u32) -> Self {
550 self.border_width = Some(border_width);
551 self
552 }
553
554 pub fn child(mut self, child: &Widget) -> Self {
555 self.child = Some(child.clone());
556 self
557 }
558
559 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
560 self.resize_mode = Some(resize_mode);
561 self
562 }
563
564 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
565 self.app_paintable = Some(app_paintable);
566 self
567 }
568
569 pub fn can_default(mut self, can_default: bool) -> Self {
570 self.can_default = Some(can_default);
571 self
572 }
573
574 pub fn can_focus(mut self, can_focus: bool) -> Self {
575 self.can_focus = Some(can_focus);
576 self
577 }
578
579 pub fn events(mut self, events: gdk::EventMask) -> Self {
580 self.events = Some(events);
581 self
582 }
583
584 pub fn expand(mut self, expand: bool) -> Self {
585 self.expand = Some(expand);
586 self
587 }
588
589 #[cfg(any(feature = "v3_20", feature = "dox"))]
590 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
591 self.focus_on_click = Some(focus_on_click);
592 self
593 }
594
595 pub fn halign(mut self, halign: Align) -> Self {
596 self.halign = Some(halign);
597 self
598 }
599
600 pub fn has_default(mut self, has_default: bool) -> Self {
601 self.has_default = Some(has_default);
602 self
603 }
604
605 pub fn has_focus(mut self, has_focus: bool) -> Self {
606 self.has_focus = Some(has_focus);
607 self
608 }
609
610 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
611 self.has_tooltip = Some(has_tooltip);
612 self
613 }
614
615 pub fn height_request(mut self, height_request: i32) -> Self {
616 self.height_request = Some(height_request);
617 self
618 }
619
620 pub fn hexpand(mut self, hexpand: bool) -> Self {
621 self.hexpand = Some(hexpand);
622 self
623 }
624
625 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
626 self.hexpand_set = Some(hexpand_set);
627 self
628 }
629
630 pub fn is_focus(mut self, is_focus: bool) -> Self {
631 self.is_focus = Some(is_focus);
632 self
633 }
634
635 pub fn margin(mut self, margin: i32) -> Self {
636 self.margin = Some(margin);
637 self
638 }
639
640 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
641 self.margin_bottom = Some(margin_bottom);
642 self
643 }
644
645 pub fn margin_end(mut self, margin_end: i32) -> Self {
646 self.margin_end = Some(margin_end);
647 self
648 }
649
650 pub fn margin_start(mut self, margin_start: i32) -> Self {
651 self.margin_start = Some(margin_start);
652 self
653 }
654
655 pub fn margin_top(mut self, margin_top: i32) -> Self {
656 self.margin_top = Some(margin_top);
657 self
658 }
659
660 pub fn name(mut self, name: &str) -> Self {
661 self.name = Some(name.to_string());
662 self
663 }
664
665 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
666 self.no_show_all = Some(no_show_all);
667 self
668 }
669
670 pub fn opacity(mut self, opacity: f64) -> Self {
671 self.opacity = Some(opacity);
672 self
673 }
674
675 pub fn parent(mut self, parent: &Container) -> Self {
676 self.parent = Some(parent.clone());
677 self
678 }
679
680 pub fn receives_default(mut self, receives_default: bool) -> Self {
681 self.receives_default = Some(receives_default);
682 self
683 }
684
685 pub fn sensitive(mut self, sensitive: bool) -> Self {
686 self.sensitive = Some(sensitive);
687 self
688 }
689
690 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
691 self.tooltip_markup = Some(tooltip_markup.to_string());
692 self
693 }
694
695 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
696 self.tooltip_text = Some(tooltip_text.to_string());
697 self
698 }
699
700 pub fn valign(mut self, valign: Align) -> Self {
701 self.valign = Some(valign);
702 self
703 }
704
705 pub fn vexpand(mut self, vexpand: bool) -> Self {
706 self.vexpand = Some(vexpand);
707 self
708 }
709
710 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
711 self.vexpand_set = Some(vexpand_set);
712 self
713 }
714
715 pub fn visible(mut self, visible: bool) -> Self {
716 self.visible = Some(visible);
717 self
718 }
719
720 pub fn width_request(mut self, width_request: i32) -> Self {
721 self.width_request = Some(width_request);
722 self
723 }
724}
725
726pub const NONE_DIALOG: Option<&Dialog> = None;
727
728pub trait DialogExt: 'static {
729 fn add_action_widget<P: IsA<Widget>>(&self, child: &P, response_id: ResponseType);
730
731 fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget;
732
733 fn get_content_area(&self) -> Box;
736
737 fn get_header_bar(&self) -> Option<Widget>;
738
739 fn get_response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType;
740
741 fn get_widget_for_response(&self, response_id: ResponseType) -> Option<Widget>;
742
743 fn response(&self, response_id: ResponseType);
744
745 fn run(&self) -> ResponseType;
746
747 fn set_default_response(&self, response_id: ResponseType);
748
749 fn set_response_sensitive(&self, response_id: ResponseType, setting: bool);
750
751 fn get_property_use_header_bar(&self) -> i32;
752
753 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
754
755 fn emit_close(&self);
756
757 fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId;
758}
759
760impl<O: IsA<Dialog>> DialogExt for O {
761 fn add_action_widget<P: IsA<Widget>>(&self, child: &P, response_id: ResponseType) {
762 unsafe {
763 gtk_sys::gtk_dialog_add_action_widget(
764 self.as_ref().to_glib_none().0,
765 child.as_ref().to_glib_none().0,
766 response_id.to_glib(),
767 );
768 }
769 }
770
771 fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget {
772 unsafe {
773 from_glib_none(gtk_sys::gtk_dialog_add_button(
774 self.as_ref().to_glib_none().0,
775 button_text.to_glib_none().0,
776 response_id.to_glib(),
777 ))
778 }
779 }
780
781 fn get_content_area(&self) -> Box {
786 unsafe {
787 from_glib_none(gtk_sys::gtk_dialog_get_content_area(
788 self.as_ref().to_glib_none().0,
789 ))
790 }
791 }
792
793 fn get_header_bar(&self) -> Option<Widget> {
794 unsafe {
795 from_glib_none(gtk_sys::gtk_dialog_get_header_bar(
796 self.as_ref().to_glib_none().0,
797 ))
798 }
799 }
800
801 fn get_response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType {
802 unsafe {
803 from_glib(gtk_sys::gtk_dialog_get_response_for_widget(
804 self.as_ref().to_glib_none().0,
805 widget.as_ref().to_glib_none().0,
806 ))
807 }
808 }
809
810 fn get_widget_for_response(&self, response_id: ResponseType) -> Option<Widget> {
811 unsafe {
812 from_glib_none(gtk_sys::gtk_dialog_get_widget_for_response(
813 self.as_ref().to_glib_none().0,
814 response_id.to_glib(),
815 ))
816 }
817 }
818
819 fn response(&self, response_id: ResponseType) {
820 unsafe {
821 gtk_sys::gtk_dialog_response(self.as_ref().to_glib_none().0, response_id.to_glib());
822 }
823 }
824
825 fn run(&self) -> ResponseType {
826 unsafe { from_glib(gtk_sys::gtk_dialog_run(self.as_ref().to_glib_none().0)) }
827 }
828
829 fn set_default_response(&self, response_id: ResponseType) {
830 unsafe {
831 gtk_sys::gtk_dialog_set_default_response(
832 self.as_ref().to_glib_none().0,
833 response_id.to_glib(),
834 );
835 }
836 }
837
838 fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
839 unsafe {
840 gtk_sys::gtk_dialog_set_response_sensitive(
841 self.as_ref().to_glib_none().0,
842 response_id.to_glib(),
843 setting.to_glib(),
844 );
845 }
846 }
847
848 fn get_property_use_header_bar(&self) -> i32 {
849 unsafe {
850 let mut value = Value::from_type(<i32 as StaticType>::static_type());
851 gobject_sys::g_object_get_property(
852 self.to_glib_none().0 as *mut gobject_sys::GObject,
853 b"use-header-bar\0".as_ptr() as *const _,
854 value.to_glib_none_mut().0,
855 );
856 value.get().unwrap()
857 }
858 }
859
860 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
861 unsafe extern "C" fn close_trampoline<P, F: Fn(&P) + 'static>(
862 this: *mut gtk_sys::GtkDialog,
863 f: glib_sys::gpointer,
864 ) where
865 P: IsA<Dialog>,
866 {
867 let f: &F = &*(f as *const F);
868 f(&Dialog::from_glib_borrow(this).unsafe_cast())
869 }
870 unsafe {
871 let f: Box_<F> = Box_::new(f);
872 connect_raw(
873 self.as_ptr() as *mut _,
874 b"close\0".as_ptr() as *const _,
875 Some(transmute(close_trampoline::<Self, F> as usize)),
876 Box_::into_raw(f),
877 )
878 }
879 }
880
881 fn emit_close(&self) {
882 let _ = unsafe {
883 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
884 .emit("close", &[])
885 .unwrap()
886 };
887 }
888
889 fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
890 unsafe extern "C" fn response_trampoline<P, F: Fn(&P, ResponseType) + 'static>(
891 this: *mut gtk_sys::GtkDialog,
892 response_id: gtk_sys::GtkResponseType,
893 f: glib_sys::gpointer,
894 ) where
895 P: IsA<Dialog>,
896 {
897 let f: &F = &*(f as *const F);
898 f(
899 &Dialog::from_glib_borrow(this).unsafe_cast(),
900 from_glib(response_id),
901 )
902 }
903 unsafe {
904 let f: Box_<F> = Box_::new(f);
905 connect_raw(
906 self.as_ptr() as *mut _,
907 b"response\0".as_ptr() as *const _,
908 Some(transmute(response_trampoline::<Self, F> as usize)),
909 Box_::into_raw(f),
910 )
911 }
912 }
913}
914
915impl fmt::Display for Dialog {
916 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
917 write!(f, "Dialog")
918 }
919}