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