1use gdk;
6use glib;
7use glib::object::Cast;
8use glib::object::IsA;
9use glib::object::ObjectExt;
10use glib::signal::connect_raw;
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13use glib::StaticType;
14use glib::ToValue;
15use glib::Value;
16use glib_sys;
17use gobject_sys;
18use gtk_sys;
19use std::boxed::Box as Box_;
20use std::fmt;
21use std::mem::transmute;
22use Align;
23use Buildable;
24use Container;
25use Orientable;
26use Orientation;
27use ResizeMode;
28use ScrollType;
29use Widget;
30
31glib_wrapper! {
32 pub struct Paned(Object<gtk_sys::GtkPaned, gtk_sys::GtkPanedClass, PanedClass>) @extends Container, Widget, @implements Buildable, Orientable;
33
34 match fn {
35 get_type => || gtk_sys::gtk_paned_get_type(),
36 }
37}
38
39impl Paned {
40 pub fn new(orientation: Orientation) -> Paned {
41 assert_initialized_main_thread!();
42 unsafe {
43 Widget::from_glib_none(gtk_sys::gtk_paned_new(orientation.to_glib())).unsafe_cast()
44 }
45 }
46}
47
48pub struct PanedBuilder {
49 position: Option<i32>,
50 position_set: Option<bool>,
51 #[cfg(any(feature = "v3_16", feature = "dox"))]
52 wide_handle: Option<bool>,
53 border_width: Option<u32>,
54 child: Option<Widget>,
55 resize_mode: Option<ResizeMode>,
56 app_paintable: Option<bool>,
57 can_default: Option<bool>,
58 can_focus: Option<bool>,
59 events: Option<gdk::EventMask>,
60 expand: Option<bool>,
61 #[cfg(any(feature = "v3_20", feature = "dox"))]
62 focus_on_click: Option<bool>,
63 halign: Option<Align>,
64 has_default: Option<bool>,
65 has_focus: Option<bool>,
66 has_tooltip: Option<bool>,
67 height_request: Option<i32>,
68 hexpand: Option<bool>,
69 hexpand_set: Option<bool>,
70 is_focus: Option<bool>,
71 margin: Option<i32>,
72 margin_bottom: Option<i32>,
73 margin_end: Option<i32>,
74 margin_start: Option<i32>,
75 margin_top: Option<i32>,
76 name: Option<String>,
77 no_show_all: Option<bool>,
78 opacity: Option<f64>,
79 parent: Option<Container>,
80 receives_default: Option<bool>,
81 sensitive: Option<bool>,
82 tooltip_markup: Option<String>,
84 tooltip_text: Option<String>,
85 valign: Option<Align>,
86 vexpand: Option<bool>,
87 vexpand_set: Option<bool>,
88 visible: Option<bool>,
89 width_request: Option<i32>,
90}
91
92impl PanedBuilder {
93 pub fn new() -> Self {
94 Self {
95 position: None,
96 position_set: None,
97 #[cfg(any(feature = "v3_16", feature = "dox"))]
98 wide_handle: None,
99 border_width: None,
100 child: None,
101 resize_mode: None,
102 app_paintable: None,
103 can_default: None,
104 can_focus: None,
105 events: None,
106 expand: None,
107 #[cfg(any(feature = "v3_20", feature = "dox"))]
108 focus_on_click: None,
109 halign: None,
110 has_default: None,
111 has_focus: None,
112 has_tooltip: None,
113 height_request: None,
114 hexpand: None,
115 hexpand_set: None,
116 is_focus: None,
117 margin: None,
118 margin_bottom: None,
119 margin_end: None,
120 margin_start: None,
121 margin_top: None,
122 name: None,
123 no_show_all: None,
124 opacity: None,
125 parent: None,
126 receives_default: None,
127 sensitive: None,
128 tooltip_markup: None,
129 tooltip_text: None,
130 valign: None,
131 vexpand: None,
132 vexpand_set: None,
133 visible: None,
134 width_request: None,
135 }
136 }
137
138 pub fn build(self) -> Paned {
139 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
140 if let Some(ref position) = self.position {
141 properties.push(("position", position));
142 }
143 if let Some(ref position_set) = self.position_set {
144 properties.push(("position-set", position_set));
145 }
146 #[cfg(any(feature = "v3_16", feature = "dox"))]
147 {
148 if let Some(ref wide_handle) = self.wide_handle {
149 properties.push(("wide-handle", wide_handle));
150 }
151 }
152 if let Some(ref border_width) = self.border_width {
153 properties.push(("border-width", border_width));
154 }
155 if let Some(ref child) = self.child {
156 properties.push(("child", child));
157 }
158 if let Some(ref resize_mode) = self.resize_mode {
159 properties.push(("resize-mode", resize_mode));
160 }
161 if let Some(ref app_paintable) = self.app_paintable {
162 properties.push(("app-paintable", app_paintable));
163 }
164 if let Some(ref can_default) = self.can_default {
165 properties.push(("can-default", can_default));
166 }
167 if let Some(ref can_focus) = self.can_focus {
168 properties.push(("can-focus", can_focus));
169 }
170 if let Some(ref events) = self.events {
171 properties.push(("events", events));
172 }
173 if let Some(ref expand) = self.expand {
174 properties.push(("expand", expand));
175 }
176 #[cfg(any(feature = "v3_20", feature = "dox"))]
177 {
178 if let Some(ref focus_on_click) = self.focus_on_click {
179 properties.push(("focus-on-click", focus_on_click));
180 }
181 }
182 if let Some(ref halign) = self.halign {
183 properties.push(("halign", halign));
184 }
185 if let Some(ref has_default) = self.has_default {
186 properties.push(("has-default", has_default));
187 }
188 if let Some(ref has_focus) = self.has_focus {
189 properties.push(("has-focus", has_focus));
190 }
191 if let Some(ref has_tooltip) = self.has_tooltip {
192 properties.push(("has-tooltip", has_tooltip));
193 }
194 if let Some(ref height_request) = self.height_request {
195 properties.push(("height-request", height_request));
196 }
197 if let Some(ref hexpand) = self.hexpand {
198 properties.push(("hexpand", hexpand));
199 }
200 if let Some(ref hexpand_set) = self.hexpand_set {
201 properties.push(("hexpand-set", hexpand_set));
202 }
203 if let Some(ref is_focus) = self.is_focus {
204 properties.push(("is-focus", is_focus));
205 }
206 if let Some(ref margin) = self.margin {
207 properties.push(("margin", margin));
208 }
209 if let Some(ref margin_bottom) = self.margin_bottom {
210 properties.push(("margin-bottom", margin_bottom));
211 }
212 if let Some(ref margin_end) = self.margin_end {
213 properties.push(("margin-end", margin_end));
214 }
215 if let Some(ref margin_start) = self.margin_start {
216 properties.push(("margin-start", margin_start));
217 }
218 if let Some(ref margin_top) = self.margin_top {
219 properties.push(("margin-top", margin_top));
220 }
221 if let Some(ref name) = self.name {
222 properties.push(("name", name));
223 }
224 if let Some(ref no_show_all) = self.no_show_all {
225 properties.push(("no-show-all", no_show_all));
226 }
227 if let Some(ref opacity) = self.opacity {
228 properties.push(("opacity", opacity));
229 }
230 if let Some(ref parent) = self.parent {
231 properties.push(("parent", parent));
232 }
233 if let Some(ref receives_default) = self.receives_default {
234 properties.push(("receives-default", receives_default));
235 }
236 if let Some(ref sensitive) = self.sensitive {
237 properties.push(("sensitive", sensitive));
238 }
239 if let Some(ref tooltip_markup) = self.tooltip_markup {
240 properties.push(("tooltip-markup", tooltip_markup));
241 }
242 if let Some(ref tooltip_text) = self.tooltip_text {
243 properties.push(("tooltip-text", tooltip_text));
244 }
245 if let Some(ref valign) = self.valign {
246 properties.push(("valign", valign));
247 }
248 if let Some(ref vexpand) = self.vexpand {
249 properties.push(("vexpand", vexpand));
250 }
251 if let Some(ref vexpand_set) = self.vexpand_set {
252 properties.push(("vexpand-set", vexpand_set));
253 }
254 if let Some(ref visible) = self.visible {
255 properties.push(("visible", visible));
256 }
257 if let Some(ref width_request) = self.width_request {
258 properties.push(("width-request", width_request));
259 }
260 glib::Object::new(Paned::static_type(), &properties)
261 .expect("object new")
262 .downcast()
263 .expect("downcast")
264 }
265
266 pub fn position(mut self, position: i32) -> Self {
267 self.position = Some(position);
268 self
269 }
270
271 pub fn position_set(mut self, position_set: bool) -> Self {
272 self.position_set = Some(position_set);
273 self
274 }
275
276 #[cfg(any(feature = "v3_16", feature = "dox"))]
277 pub fn wide_handle(mut self, wide_handle: bool) -> Self {
278 self.wide_handle = Some(wide_handle);
279 self
280 }
281
282 pub fn border_width(mut self, border_width: u32) -> Self {
283 self.border_width = Some(border_width);
284 self
285 }
286
287 pub fn child(mut self, child: &Widget) -> Self {
288 self.child = Some(child.clone());
289 self
290 }
291
292 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
293 self.resize_mode = Some(resize_mode);
294 self
295 }
296
297 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
298 self.app_paintable = Some(app_paintable);
299 self
300 }
301
302 pub fn can_default(mut self, can_default: bool) -> Self {
303 self.can_default = Some(can_default);
304 self
305 }
306
307 pub fn can_focus(mut self, can_focus: bool) -> Self {
308 self.can_focus = Some(can_focus);
309 self
310 }
311
312 pub fn events(mut self, events: gdk::EventMask) -> Self {
313 self.events = Some(events);
314 self
315 }
316
317 pub fn expand(mut self, expand: bool) -> Self {
318 self.expand = Some(expand);
319 self
320 }
321
322 #[cfg(any(feature = "v3_20", feature = "dox"))]
323 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
324 self.focus_on_click = Some(focus_on_click);
325 self
326 }
327
328 pub fn halign(mut self, halign: Align) -> Self {
329 self.halign = Some(halign);
330 self
331 }
332
333 pub fn has_default(mut self, has_default: bool) -> Self {
334 self.has_default = Some(has_default);
335 self
336 }
337
338 pub fn has_focus(mut self, has_focus: bool) -> Self {
339 self.has_focus = Some(has_focus);
340 self
341 }
342
343 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
344 self.has_tooltip = Some(has_tooltip);
345 self
346 }
347
348 pub fn height_request(mut self, height_request: i32) -> Self {
349 self.height_request = Some(height_request);
350 self
351 }
352
353 pub fn hexpand(mut self, hexpand: bool) -> Self {
354 self.hexpand = Some(hexpand);
355 self
356 }
357
358 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
359 self.hexpand_set = Some(hexpand_set);
360 self
361 }
362
363 pub fn is_focus(mut self, is_focus: bool) -> Self {
364 self.is_focus = Some(is_focus);
365 self
366 }
367
368 pub fn margin(mut self, margin: i32) -> Self {
369 self.margin = Some(margin);
370 self
371 }
372
373 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
374 self.margin_bottom = Some(margin_bottom);
375 self
376 }
377
378 pub fn margin_end(mut self, margin_end: i32) -> Self {
379 self.margin_end = Some(margin_end);
380 self
381 }
382
383 pub fn margin_start(mut self, margin_start: i32) -> Self {
384 self.margin_start = Some(margin_start);
385 self
386 }
387
388 pub fn margin_top(mut self, margin_top: i32) -> Self {
389 self.margin_top = Some(margin_top);
390 self
391 }
392
393 pub fn name(mut self, name: &str) -> Self {
394 self.name = Some(name.to_string());
395 self
396 }
397
398 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
399 self.no_show_all = Some(no_show_all);
400 self
401 }
402
403 pub fn opacity(mut self, opacity: f64) -> Self {
404 self.opacity = Some(opacity);
405 self
406 }
407
408 pub fn parent(mut self, parent: &Container) -> Self {
409 self.parent = Some(parent.clone());
410 self
411 }
412
413 pub fn receives_default(mut self, receives_default: bool) -> Self {
414 self.receives_default = Some(receives_default);
415 self
416 }
417
418 pub fn sensitive(mut self, sensitive: bool) -> Self {
419 self.sensitive = Some(sensitive);
420 self
421 }
422
423 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
424 self.tooltip_markup = Some(tooltip_markup.to_string());
425 self
426 }
427
428 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
429 self.tooltip_text = Some(tooltip_text.to_string());
430 self
431 }
432
433 pub fn valign(mut self, valign: Align) -> Self {
434 self.valign = Some(valign);
435 self
436 }
437
438 pub fn vexpand(mut self, vexpand: bool) -> Self {
439 self.vexpand = Some(vexpand);
440 self
441 }
442
443 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
444 self.vexpand_set = Some(vexpand_set);
445 self
446 }
447
448 pub fn visible(mut self, visible: bool) -> Self {
449 self.visible = Some(visible);
450 self
451 }
452
453 pub fn width_request(mut self, width_request: i32) -> Self {
454 self.width_request = Some(width_request);
455 self
456 }
457}
458
459pub const NONE_PANED: Option<&Paned> = None;
460
461pub trait PanedExt: 'static {
462 fn add1<P: IsA<Widget>>(&self, child: &P);
463
464 fn add2<P: IsA<Widget>>(&self, child: &P);
465
466 fn get_child1(&self) -> Option<Widget>;
467
468 fn get_child2(&self) -> Option<Widget>;
469
470 fn get_handle_window(&self) -> Option<gdk::Window>;
471
472 fn get_position(&self) -> i32;
473
474 #[cfg(any(feature = "v3_16", feature = "dox"))]
475 fn get_wide_handle(&self) -> bool;
476
477 fn pack1<P: IsA<Widget>>(&self, child: &P, resize: bool, shrink: bool);
478
479 fn pack2<P: IsA<Widget>>(&self, child: &P, resize: bool, shrink: bool);
480
481 fn set_position(&self, position: i32);
482
483 #[cfg(any(feature = "v3_16", feature = "dox"))]
484 fn set_wide_handle(&self, wide: bool);
485
486 fn get_property_max_position(&self) -> i32;
487
488 fn get_property_min_position(&self) -> i32;
489
490 fn get_property_position_set(&self) -> bool;
491
492 fn set_property_position_set(&self, position_set: bool);
493
494 fn get_child_resize<T: IsA<Widget>>(&self, item: &T) -> bool;
495
496 fn set_child_resize<T: IsA<Widget>>(&self, item: &T, resize: bool);
497
498 fn get_child_shrink<T: IsA<Widget>>(&self, item: &T) -> bool;
499
500 fn set_child_shrink<T: IsA<Widget>>(&self, item: &T, shrink: bool);
501
502 fn connect_accept_position<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;
503
504 fn emit_accept_position(&self) -> bool;
505
506 fn connect_cancel_position<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;
507
508 fn emit_cancel_position(&self) -> bool;
509
510 fn connect_cycle_child_focus<F: Fn(&Self, bool) -> bool + 'static>(
511 &self,
512 f: F,
513 ) -> SignalHandlerId;
514
515 fn emit_cycle_child_focus(&self, reversed: bool) -> bool;
516
517 fn connect_cycle_handle_focus<F: Fn(&Self, bool) -> bool + 'static>(
518 &self,
519 f: F,
520 ) -> SignalHandlerId;
521
522 fn emit_cycle_handle_focus(&self, reversed: bool) -> bool;
523
524 fn connect_move_handle<F: Fn(&Self, ScrollType) -> bool + 'static>(
525 &self,
526 f: F,
527 ) -> SignalHandlerId;
528
529 fn emit_move_handle(&self, scroll_type: ScrollType) -> bool;
530
531 fn connect_toggle_handle_focus<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;
532
533 fn emit_toggle_handle_focus(&self) -> bool;
534
535 fn connect_property_max_position_notify<F: Fn(&Self) + 'static>(&self, f: F)
536 -> SignalHandlerId;
537
538 fn connect_property_min_position_notify<F: Fn(&Self) + 'static>(&self, f: F)
539 -> SignalHandlerId;
540
541 fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
542
543 fn connect_property_position_set_notify<F: Fn(&Self) + 'static>(&self, f: F)
544 -> SignalHandlerId;
545
546 #[cfg(any(feature = "v3_16", feature = "dox"))]
547 fn connect_property_wide_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
548}
549
550impl<O: IsA<Paned>> PanedExt for O {
551 fn add1<P: IsA<Widget>>(&self, child: &P) {
552 unsafe {
553 gtk_sys::gtk_paned_add1(
554 self.as_ref().to_glib_none().0,
555 child.as_ref().to_glib_none().0,
556 );
557 }
558 }
559
560 fn add2<P: IsA<Widget>>(&self, child: &P) {
561 unsafe {
562 gtk_sys::gtk_paned_add2(
563 self.as_ref().to_glib_none().0,
564 child.as_ref().to_glib_none().0,
565 );
566 }
567 }
568
569 fn get_child1(&self) -> Option<Widget> {
570 unsafe {
571 from_glib_none(gtk_sys::gtk_paned_get_child1(
572 self.as_ref().to_glib_none().0,
573 ))
574 }
575 }
576
577 fn get_child2(&self) -> Option<Widget> {
578 unsafe {
579 from_glib_none(gtk_sys::gtk_paned_get_child2(
580 self.as_ref().to_glib_none().0,
581 ))
582 }
583 }
584
585 fn get_handle_window(&self) -> Option<gdk::Window> {
586 unsafe {
587 from_glib_none(gtk_sys::gtk_paned_get_handle_window(
588 self.as_ref().to_glib_none().0,
589 ))
590 }
591 }
592
593 fn get_position(&self) -> i32 {
594 unsafe { gtk_sys::gtk_paned_get_position(self.as_ref().to_glib_none().0) }
595 }
596
597 #[cfg(any(feature = "v3_16", feature = "dox"))]
598 fn get_wide_handle(&self) -> bool {
599 unsafe {
600 from_glib(gtk_sys::gtk_paned_get_wide_handle(
601 self.as_ref().to_glib_none().0,
602 ))
603 }
604 }
605
606 fn pack1<P: IsA<Widget>>(&self, child: &P, resize: bool, shrink: bool) {
607 unsafe {
608 gtk_sys::gtk_paned_pack1(
609 self.as_ref().to_glib_none().0,
610 child.as_ref().to_glib_none().0,
611 resize.to_glib(),
612 shrink.to_glib(),
613 );
614 }
615 }
616
617 fn pack2<P: IsA<Widget>>(&self, child: &P, resize: bool, shrink: bool) {
618 unsafe {
619 gtk_sys::gtk_paned_pack2(
620 self.as_ref().to_glib_none().0,
621 child.as_ref().to_glib_none().0,
622 resize.to_glib(),
623 shrink.to_glib(),
624 );
625 }
626 }
627
628 fn set_position(&self, position: i32) {
629 unsafe {
630 gtk_sys::gtk_paned_set_position(self.as_ref().to_glib_none().0, position);
631 }
632 }
633
634 #[cfg(any(feature = "v3_16", feature = "dox"))]
635 fn set_wide_handle(&self, wide: bool) {
636 unsafe {
637 gtk_sys::gtk_paned_set_wide_handle(self.as_ref().to_glib_none().0, wide.to_glib());
638 }
639 }
640
641 fn get_property_max_position(&self) -> i32 {
642 unsafe {
643 let mut value = Value::from_type(<i32 as StaticType>::static_type());
644 gobject_sys::g_object_get_property(
645 self.to_glib_none().0 as *mut gobject_sys::GObject,
646 b"max-position\0".as_ptr() as *const _,
647 value.to_glib_none_mut().0,
648 );
649 value.get().unwrap()
650 }
651 }
652
653 fn get_property_min_position(&self) -> i32 {
654 unsafe {
655 let mut value = Value::from_type(<i32 as StaticType>::static_type());
656 gobject_sys::g_object_get_property(
657 self.to_glib_none().0 as *mut gobject_sys::GObject,
658 b"min-position\0".as_ptr() as *const _,
659 value.to_glib_none_mut().0,
660 );
661 value.get().unwrap()
662 }
663 }
664
665 fn get_property_position_set(&self) -> bool {
666 unsafe {
667 let mut value = Value::from_type(<bool as StaticType>::static_type());
668 gobject_sys::g_object_get_property(
669 self.to_glib_none().0 as *mut gobject_sys::GObject,
670 b"position-set\0".as_ptr() as *const _,
671 value.to_glib_none_mut().0,
672 );
673 value.get().unwrap()
674 }
675 }
676
677 fn set_property_position_set(&self, position_set: bool) {
678 unsafe {
679 gobject_sys::g_object_set_property(
680 self.to_glib_none().0 as *mut gobject_sys::GObject,
681 b"position-set\0".as_ptr() as *const _,
682 Value::from(&position_set).to_glib_none().0,
683 );
684 }
685 }
686
687 fn get_child_resize<T: IsA<Widget>>(&self, item: &T) -> bool {
688 unsafe {
689 let mut value = Value::from_type(<bool as StaticType>::static_type());
690 gtk_sys::gtk_container_child_get_property(
691 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
692 item.to_glib_none().0 as *mut _,
693 b"resize\0".as_ptr() as *const _,
694 value.to_glib_none_mut().0,
695 );
696 value.get().unwrap()
697 }
698 }
699
700 fn set_child_resize<T: IsA<Widget>>(&self, item: &T, resize: bool) {
701 unsafe {
702 gtk_sys::gtk_container_child_set_property(
703 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
704 item.to_glib_none().0 as *mut _,
705 b"resize\0".as_ptr() as *const _,
706 Value::from(&resize).to_glib_none().0,
707 );
708 }
709 }
710
711 fn get_child_shrink<T: IsA<Widget>>(&self, item: &T) -> bool {
712 unsafe {
713 let mut value = Value::from_type(<bool as StaticType>::static_type());
714 gtk_sys::gtk_container_child_get_property(
715 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
716 item.to_glib_none().0 as *mut _,
717 b"shrink\0".as_ptr() as *const _,
718 value.to_glib_none_mut().0,
719 );
720 value.get().unwrap()
721 }
722 }
723
724 fn set_child_shrink<T: IsA<Widget>>(&self, item: &T, shrink: bool) {
725 unsafe {
726 gtk_sys::gtk_container_child_set_property(
727 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
728 item.to_glib_none().0 as *mut _,
729 b"shrink\0".as_ptr() as *const _,
730 Value::from(&shrink).to_glib_none().0,
731 );
732 }
733 }
734
735 fn connect_accept_position<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
736 unsafe extern "C" fn accept_position_trampoline<P, F: Fn(&P) -> bool + 'static>(
737 this: *mut gtk_sys::GtkPaned,
738 f: glib_sys::gpointer,
739 ) -> glib_sys::gboolean
740 where
741 P: IsA<Paned>,
742 {
743 let f: &F = &*(f as *const F);
744 f(&Paned::from_glib_borrow(this).unsafe_cast()).to_glib()
745 }
746 unsafe {
747 let f: Box_<F> = Box_::new(f);
748 connect_raw(
749 self.as_ptr() as *mut _,
750 b"accept-position\0".as_ptr() as *const _,
751 Some(transmute(accept_position_trampoline::<Self, F> as usize)),
752 Box_::into_raw(f),
753 )
754 }
755 }
756
757 fn emit_accept_position(&self) -> bool {
758 let res = unsafe {
759 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
760 .emit("accept-position", &[])
761 .unwrap()
762 };
763 res.unwrap().get().unwrap()
764 }
765
766 fn connect_cancel_position<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
767 unsafe extern "C" fn cancel_position_trampoline<P, F: Fn(&P) -> bool + 'static>(
768 this: *mut gtk_sys::GtkPaned,
769 f: glib_sys::gpointer,
770 ) -> glib_sys::gboolean
771 where
772 P: IsA<Paned>,
773 {
774 let f: &F = &*(f as *const F);
775 f(&Paned::from_glib_borrow(this).unsafe_cast()).to_glib()
776 }
777 unsafe {
778 let f: Box_<F> = Box_::new(f);
779 connect_raw(
780 self.as_ptr() as *mut _,
781 b"cancel-position\0".as_ptr() as *const _,
782 Some(transmute(cancel_position_trampoline::<Self, F> as usize)),
783 Box_::into_raw(f),
784 )
785 }
786 }
787
788 fn emit_cancel_position(&self) -> bool {
789 let res = unsafe {
790 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
791 .emit("cancel-position", &[])
792 .unwrap()
793 };
794 res.unwrap().get().unwrap()
795 }
796
797 fn connect_cycle_child_focus<F: Fn(&Self, bool) -> bool + 'static>(
798 &self,
799 f: F,
800 ) -> SignalHandlerId {
801 unsafe extern "C" fn cycle_child_focus_trampoline<P, F: Fn(&P, bool) -> bool + 'static>(
802 this: *mut gtk_sys::GtkPaned,
803 reversed: glib_sys::gboolean,
804 f: glib_sys::gpointer,
805 ) -> glib_sys::gboolean
806 where
807 P: IsA<Paned>,
808 {
809 let f: &F = &*(f as *const F);
810 f(
811 &Paned::from_glib_borrow(this).unsafe_cast(),
812 from_glib(reversed),
813 )
814 .to_glib()
815 }
816 unsafe {
817 let f: Box_<F> = Box_::new(f);
818 connect_raw(
819 self.as_ptr() as *mut _,
820 b"cycle-child-focus\0".as_ptr() as *const _,
821 Some(transmute(cycle_child_focus_trampoline::<Self, F> as usize)),
822 Box_::into_raw(f),
823 )
824 }
825 }
826
827 fn emit_cycle_child_focus(&self, reversed: bool) -> bool {
828 let res = unsafe {
829 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
830 .emit("cycle-child-focus", &[&reversed])
831 .unwrap()
832 };
833 res.unwrap().get().unwrap()
834 }
835
836 fn connect_cycle_handle_focus<F: Fn(&Self, bool) -> bool + 'static>(
837 &self,
838 f: F,
839 ) -> SignalHandlerId {
840 unsafe extern "C" fn cycle_handle_focus_trampoline<P, F: Fn(&P, bool) -> bool + 'static>(
841 this: *mut gtk_sys::GtkPaned,
842 reversed: glib_sys::gboolean,
843 f: glib_sys::gpointer,
844 ) -> glib_sys::gboolean
845 where
846 P: IsA<Paned>,
847 {
848 let f: &F = &*(f as *const F);
849 f(
850 &Paned::from_glib_borrow(this).unsafe_cast(),
851 from_glib(reversed),
852 )
853 .to_glib()
854 }
855 unsafe {
856 let f: Box_<F> = Box_::new(f);
857 connect_raw(
858 self.as_ptr() as *mut _,
859 b"cycle-handle-focus\0".as_ptr() as *const _,
860 Some(transmute(cycle_handle_focus_trampoline::<Self, F> as usize)),
861 Box_::into_raw(f),
862 )
863 }
864 }
865
866 fn emit_cycle_handle_focus(&self, reversed: bool) -> bool {
867 let res = unsafe {
868 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
869 .emit("cycle-handle-focus", &[&reversed])
870 .unwrap()
871 };
872 res.unwrap().get().unwrap()
873 }
874
875 fn connect_move_handle<F: Fn(&Self, ScrollType) -> bool + 'static>(
876 &self,
877 f: F,
878 ) -> SignalHandlerId {
879 unsafe extern "C" fn move_handle_trampoline<P, F: Fn(&P, ScrollType) -> bool + 'static>(
880 this: *mut gtk_sys::GtkPaned,
881 scroll_type: gtk_sys::GtkScrollType,
882 f: glib_sys::gpointer,
883 ) -> glib_sys::gboolean
884 where
885 P: IsA<Paned>,
886 {
887 let f: &F = &*(f as *const F);
888 f(
889 &Paned::from_glib_borrow(this).unsafe_cast(),
890 from_glib(scroll_type),
891 )
892 .to_glib()
893 }
894 unsafe {
895 let f: Box_<F> = Box_::new(f);
896 connect_raw(
897 self.as_ptr() as *mut _,
898 b"move-handle\0".as_ptr() as *const _,
899 Some(transmute(move_handle_trampoline::<Self, F> as usize)),
900 Box_::into_raw(f),
901 )
902 }
903 }
904
905 fn emit_move_handle(&self, scroll_type: ScrollType) -> bool {
906 let res = unsafe {
907 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
908 .emit("move-handle", &[&scroll_type])
909 .unwrap()
910 };
911 res.unwrap().get().unwrap()
912 }
913
914 fn connect_toggle_handle_focus<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
915 unsafe extern "C" fn toggle_handle_focus_trampoline<P, F: Fn(&P) -> bool + 'static>(
916 this: *mut gtk_sys::GtkPaned,
917 f: glib_sys::gpointer,
918 ) -> glib_sys::gboolean
919 where
920 P: IsA<Paned>,
921 {
922 let f: &F = &*(f as *const F);
923 f(&Paned::from_glib_borrow(this).unsafe_cast()).to_glib()
924 }
925 unsafe {
926 let f: Box_<F> = Box_::new(f);
927 connect_raw(
928 self.as_ptr() as *mut _,
929 b"toggle-handle-focus\0".as_ptr() as *const _,
930 Some(transmute(
931 toggle_handle_focus_trampoline::<Self, F> as usize,
932 )),
933 Box_::into_raw(f),
934 )
935 }
936 }
937
938 fn emit_toggle_handle_focus(&self) -> bool {
939 let res = unsafe {
940 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
941 .emit("toggle-handle-focus", &[])
942 .unwrap()
943 };
944 res.unwrap().get().unwrap()
945 }
946
947 fn connect_property_max_position_notify<F: Fn(&Self) + 'static>(
948 &self,
949 f: F,
950 ) -> SignalHandlerId {
951 unsafe extern "C" fn notify_max_position_trampoline<P, F: Fn(&P) + 'static>(
952 this: *mut gtk_sys::GtkPaned,
953 _param_spec: glib_sys::gpointer,
954 f: glib_sys::gpointer,
955 ) where
956 P: IsA<Paned>,
957 {
958 let f: &F = &*(f as *const F);
959 f(&Paned::from_glib_borrow(this).unsafe_cast())
960 }
961 unsafe {
962 let f: Box_<F> = Box_::new(f);
963 connect_raw(
964 self.as_ptr() as *mut _,
965 b"notify::max-position\0".as_ptr() as *const _,
966 Some(transmute(
967 notify_max_position_trampoline::<Self, F> as usize,
968 )),
969 Box_::into_raw(f),
970 )
971 }
972 }
973
974 fn connect_property_min_position_notify<F: Fn(&Self) + 'static>(
975 &self,
976 f: F,
977 ) -> SignalHandlerId {
978 unsafe extern "C" fn notify_min_position_trampoline<P, F: Fn(&P) + 'static>(
979 this: *mut gtk_sys::GtkPaned,
980 _param_spec: glib_sys::gpointer,
981 f: glib_sys::gpointer,
982 ) where
983 P: IsA<Paned>,
984 {
985 let f: &F = &*(f as *const F);
986 f(&Paned::from_glib_borrow(this).unsafe_cast())
987 }
988 unsafe {
989 let f: Box_<F> = Box_::new(f);
990 connect_raw(
991 self.as_ptr() as *mut _,
992 b"notify::min-position\0".as_ptr() as *const _,
993 Some(transmute(
994 notify_min_position_trampoline::<Self, F> as usize,
995 )),
996 Box_::into_raw(f),
997 )
998 }
999 }
1000
1001 fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1002 unsafe extern "C" fn notify_position_trampoline<P, F: Fn(&P) + 'static>(
1003 this: *mut gtk_sys::GtkPaned,
1004 _param_spec: glib_sys::gpointer,
1005 f: glib_sys::gpointer,
1006 ) where
1007 P: IsA<Paned>,
1008 {
1009 let f: &F = &*(f as *const F);
1010 f(&Paned::from_glib_borrow(this).unsafe_cast())
1011 }
1012 unsafe {
1013 let f: Box_<F> = Box_::new(f);
1014 connect_raw(
1015 self.as_ptr() as *mut _,
1016 b"notify::position\0".as_ptr() as *const _,
1017 Some(transmute(notify_position_trampoline::<Self, F> as usize)),
1018 Box_::into_raw(f),
1019 )
1020 }
1021 }
1022
1023 fn connect_property_position_set_notify<F: Fn(&Self) + 'static>(
1024 &self,
1025 f: F,
1026 ) -> SignalHandlerId {
1027 unsafe extern "C" fn notify_position_set_trampoline<P, F: Fn(&P) + 'static>(
1028 this: *mut gtk_sys::GtkPaned,
1029 _param_spec: glib_sys::gpointer,
1030 f: glib_sys::gpointer,
1031 ) where
1032 P: IsA<Paned>,
1033 {
1034 let f: &F = &*(f as *const F);
1035 f(&Paned::from_glib_borrow(this).unsafe_cast())
1036 }
1037 unsafe {
1038 let f: Box_<F> = Box_::new(f);
1039 connect_raw(
1040 self.as_ptr() as *mut _,
1041 b"notify::position-set\0".as_ptr() as *const _,
1042 Some(transmute(
1043 notify_position_set_trampoline::<Self, F> as usize,
1044 )),
1045 Box_::into_raw(f),
1046 )
1047 }
1048 }
1049
1050 #[cfg(any(feature = "v3_16", feature = "dox"))]
1051 fn connect_property_wide_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1052 unsafe extern "C" fn notify_wide_handle_trampoline<P, F: Fn(&P) + 'static>(
1053 this: *mut gtk_sys::GtkPaned,
1054 _param_spec: glib_sys::gpointer,
1055 f: glib_sys::gpointer,
1056 ) where
1057 P: IsA<Paned>,
1058 {
1059 let f: &F = &*(f as *const F);
1060 f(&Paned::from_glib_borrow(this).unsafe_cast())
1061 }
1062 unsafe {
1063 let f: Box_<F> = Box_::new(f);
1064 connect_raw(
1065 self.as_ptr() as *mut _,
1066 b"notify::wide-handle\0".as_ptr() as *const _,
1067 Some(transmute(notify_wide_handle_trampoline::<Self, F> as usize)),
1068 Box_::into_raw(f),
1069 )
1070 }
1071 }
1072}
1073
1074impl fmt::Display for Paned {
1075 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1076 write!(f, "Paned")
1077 }
1078}