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