1use glib::subclass::SignalId;
4use libc::c_int;
5use std::mem;
6use std::num::NonZeroU32;
7
8use glib::Propagation;
9use glib::prelude::*;
10use glib::subclass::prelude::*;
11use glib::translate::*;
12
13use crate::DirectionType;
14use crate::DragResult;
15use crate::Orientation;
16use crate::SelectionData;
17use crate::SizeRequestMode;
18use crate::StateFlags;
19use crate::TextDirection;
20use crate::Tooltip;
21use crate::Widget;
22use crate::WidgetHelpType;
23use crate::prelude::*;
24use crate::{Allocation, ffi};
25
26pub trait WidgetImpl: ObjectImpl + ObjectSubclass<Type: IsA<Widget>> {
27 fn adjust_baseline_allocation(&self, baseline: &mut i32) {
40 self.parent_adjust_baseline_allocation(baseline)
41 }
42
43 fn adjust_baseline_request(&self, minimum_baseline: &mut i32, natural_baseline: &mut i32) {
44 self.parent_adjust_baseline_request(minimum_baseline, natural_baseline)
45 }
46
47 #[doc(alias = "get_preferred_height_and_baseline_for_width")]
74 fn preferred_height_and_baseline_for_width(&self, width: i32) -> (i32, i32, i32, i32) {
75 self.parent_preferred_height_and_baseline_for_width(width)
76 }
77
78 fn adjust_size_allocation(
94 &self,
95
96 orientation: Orientation,
97 minimum_size: &mut i32,
98 natural_size: &mut i32,
99 allocated_pos: &mut i32,
100 allocated_size: &mut i32,
101 ) {
102 self.parent_adjust_size_allocation(
103 orientation,
104 minimum_size,
105 natural_size,
106 allocated_pos,
107 allocated_size,
108 )
109 }
110
111 fn adjust_size_request(
127 &self,
128
129 orientation: Orientation,
130 minimum_size: &mut i32,
131 natural_size: &mut i32,
132 ) {
133 self.parent_adjust_size_request(orientation, minimum_size, natural_size)
134 }
135
136 fn button_press_event(&self, event: &gdk::EventButton) -> Propagation {
139 self.parent_button_press_event(event)
140 }
141
142 fn button_release_event(&self, event: &gdk::EventButton) -> Propagation {
145 self.parent_button_release_event(event)
146 }
147
148 fn child_notify(&self, child_property: &glib::ParamSpec) {
159 self.parent_child_notify(child_property)
160 }
161
162 fn composited_changed(&self) {
165 self.parent_composited_changed()
166 }
167
168 fn compute_expand(&self, hexpand: &mut bool, vexpand: &mut bool) {
171 self.parent_compute_expand(hexpand, vexpand)
172 }
173
174 fn configure_event(&self, event: &gdk::EventConfigure) -> Propagation {
177 self.parent_configure_event(event)
178 }
179
180 fn window_state_event(&self, event: &gdk::EventWindowState) -> Propagation {
183 self.parent_window_state_event(event)
184 }
185
186 fn damage_event(&self, event: &gdk::EventExpose) -> Propagation {
189 self.parent_damage_event(event)
190 }
191
192 fn delete_event(&self, event: &gdk::Event) -> Propagation {
195 self.parent_delete_event(event)
196 }
197
198 fn destroy(&self) {
199 self.parent_destroy()
200 }
201
202 fn destroy_event(&self, event: &gdk::Event) -> Propagation {
204 self.parent_destroy_event(event)
205 }
206
207 fn direction_changed(&self, previous_direction: TextDirection) {
210 self.parent_direction_changed(previous_direction)
211 }
212
213 fn dispatch_child_properties_changed(&self, pspecs: &[glib::ParamSpec]) {
215 self.parent_dispatch_child_properties_changed(pspecs)
216 }
217
218 fn drag_begin(&self, context: &gdk::DragContext) {
221 self.parent_drag_begin(context)
222 }
223
224 fn drag_data_delete(&self, context: &gdk::DragContext) {
227 self.parent_drag_data_delete(context)
228 }
229
230 fn drag_data_get(
233 &self,
234
235 context: &gdk::DragContext,
236 selection_data: &SelectionData,
237 info: u32,
238 time: u32,
239 ) {
240 self.parent_drag_data_get(context, selection_data, info, time)
241 }
242
243 fn drag_data_received(
246 &self,
247
248 context: &gdk::DragContext,
249 x: i32,
250 y: i32,
251 selection_data: &SelectionData,
252 info: u32,
253 time: u32,
254 ) {
255 self.parent_drag_data_received(context, x, y, selection_data, info, time)
256 }
257
258 fn drag_drop(&self, context: &gdk::DragContext, x: i32, y: i32, time: u32) -> Propagation {
261 self.parent_drag_drop(context, x, y, time)
262 }
263
264 fn drag_end(&self, context: &gdk::DragContext) {
267 self.parent_drag_end(context)
268 }
269
270 fn drag_failed(&self, context: &gdk::DragContext, result: DragResult) -> Propagation {
273 self.parent_drag_failed(context, result)
274 }
275
276 fn drag_leave(&self, context: &gdk::DragContext, time: u32) {
279 self.parent_drag_leave(context, time)
280 }
281
282 fn drag_motion(&self, context: &gdk::DragContext, x: i32, y: i32, time: u32) -> Propagation {
285 self.parent_drag_motion(context, x, y, time)
286 }
287
288 fn draw(&self, cr: &cairo::Context) -> Propagation {
290 self.parent_draw(cr)
291 }
292
293 fn can_activate_accel(&self, signal_id: SignalId) -> bool {
307 self.parent_can_activate_accel(signal_id)
308 }
309
310 fn request_mode(&self) -> SizeRequestMode {
322 self.parent_request_mode()
323 }
324
325 fn preferred_width(&self) -> (i32, i32) {
344 self.parent_preferred_width()
345 }
346
347 #[doc(alias = "get_preferred_width_for_height")]
367 fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
368 self.parent_preferred_width_for_height(height)
369 }
370
371 fn preferred_height(&self) -> (i32, i32) {
390 self.parent_preferred_height()
391 }
392
393 #[doc(alias = "get_preferred_height_for_width")]
413 fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
414 self.parent_preferred_height_for_width(width)
415 }
416
417 fn size_allocate(&self, allocation: &Allocation) {
431 self.parent_size_allocate(allocation)
432 }
433
434 fn realize(&self) {
453 self.parent_realize();
454 }
455
456 fn unrealize(&self) {
460 self.parent_unrealize();
461 }
462 fn map(&self) {
465 self.parent_map();
466 }
467
468 fn unmap(&self) {
471 self.parent_unmap();
472 }
473
474 fn show(&self) {
486 self.parent_show();
487 }
488
489 fn hide(&self) {
492 self.parent_hide();
493 }
494
495 fn grab_focus(&self) {
506 self.parent_grab_focus();
507 }
508
509 fn focus(&self, direction: DirectionType) -> bool {
510 self.parent_focus(direction)
511 }
512
513 fn motion_notify_event(&self, event: &gdk::EventMotion) -> Propagation {
516 self.parent_motion_notify_event(event)
517 }
518
519 fn scroll_event(&self, event: &gdk::EventScroll) -> Propagation {
522 self.parent_scroll_event(event)
523 }
524
525 fn enter_notify_event(&self, event: &gdk::EventCrossing) -> Propagation {
528 self.parent_enter_notify_event(event)
529 }
530
531 fn leave_notify_event(&self, event: &gdk::EventCrossing) -> Propagation {
534 self.parent_leave_notify_event(event)
535 }
536
537 fn focus_in_event(&self, event: &gdk::EventFocus) -> Propagation {
540 self.parent_focus_in_event(event)
541 }
542
543 fn focus_out_event(&self, event: &gdk::EventFocus) -> Propagation {
546 self.parent_focus_out_event(event)
547 }
548
549 fn key_press_event(&self, event: &gdk::EventKey) -> Propagation {
551 self.parent_key_press_event(event)
552 }
553
554 fn key_release_event(&self, event: &gdk::EventKey) -> Propagation {
556 self.parent_key_release_event(event)
557 }
558
559 fn map_event(&self, event: &gdk::Event) -> Propagation {
561 self.parent_map_event(event)
562 }
563
564 fn unmap_event(&self, event: &gdk::Event) -> Propagation {
567 self.parent_unmap_event(event)
568 }
569
570 fn show_all(&self) {
573 self.parent_show_all();
574 }
575
576 fn state_flags_changed(&self, previous_state_flags: StateFlags) {
579 self.parent_state_flags_changed(previous_state_flags);
580 }
581
582 fn parent_set(&self, previous_parent: Option<&Widget>) {
585 self.parent_parent_set(previous_parent);
586 }
587
588 fn hierarchy_changed(&self, previous_toplevel: Option<&Widget>) {
591 self.parent_hierarchy_changed(previous_toplevel);
592 }
593
594 fn grab_notify(&self, was_grabbed: bool) {
598 self.parent_grab_notify(was_grabbed);
599 }
600
601 fn mnemonic_activate(&self, group_cycling: bool) -> bool {
609 self.parent_mnemonic_activate(group_cycling)
610 }
611
612 fn move_focus(&self, direction: DirectionType) {
614 self.parent_move_focus(direction);
615 }
616
617 fn keynav_failed(&self, direction: DirectionType) -> bool {
653 self.parent_keynav_failed(direction)
654 }
655
656 fn event(&self, event: &gdk::Event) -> Propagation {
672 self.parent_event(event)
673 }
674
675 fn property_notify_event(&self, event: &gdk::EventProperty) -> Propagation {
678 self.parent_property_notify_event(event)
679 }
680
681 fn selection_clear_event(&self, event: &gdk::EventSelection) -> Propagation {
684 self.parent_selection_clear_event(event)
685 }
686
687 fn selection_request_event(&self, event: &gdk::EventSelection) -> Propagation {
691 self.parent_selection_request_event(event)
692 }
693
694 fn selection_notify_event(&self, event: &gdk::EventSelection) -> Propagation {
695 self.parent_selection_notify_event(event)
696 }
697
698 fn proximity_in_event(&self, event: &gdk::EventProximity) -> Propagation {
699 self.parent_proximity_in_event(event)
700 }
701
702 fn proximity_out_event(&self, event: &gdk::EventProximity) -> Propagation {
703 self.parent_proximity_out_event(event)
704 }
705
706 fn visibility_notify_event(&self, event: &gdk::EventVisibility) -> Propagation {
709 self.parent_visibility_notify_event(event)
710 }
711
712 fn grab_broken_event(&self, event: &gdk::EventGrabBroken) -> Propagation {
715 self.parent_grab_broken_event(event)
716 }
717
718 fn touch_event(&self, event: &gdk::EventTouch) -> Propagation {
720 self.parent_touch_event(event)
721 }
722
723 fn selection_get(&self, selection_data: &SelectionData, info: u32, time: u32) {
724 self.parent_selection_get(selection_data, info, time);
725 }
726
727 fn selection_received(&self, selection_data: &SelectionData, time: u32) {
728 self.parent_selection_received(selection_data, time);
729 }
730
731 fn popup_menu(&self) -> bool {
734 self.parent_popup_menu()
735 }
736
737 fn show_help(&self, help_type: WidgetHelpType) -> bool {
738 self.parent_show_help(help_type)
739 }
740
741 fn screen_changed(&self, previous_screen: Option<&gdk::Screen>) {
744 self.parent_screen_changed(previous_screen);
745 }
746
747 fn query_tooltip(&self, x: i32, y: i32, keyboard_tooltip: bool, tooltip: &Tooltip) -> bool {
751 self.parent_query_tooltip(x, y, keyboard_tooltip, tooltip)
752 }
753
754 fn style_updated(&self) {
757 self.parent_style_updated();
758 }
759
760 fn queue_draw_region(&self, region: &cairo::Region) {
773 self.parent_queue_draw_region(region);
774 }
775}
776
777pub trait WidgetImplExt: WidgetImpl {
778 fn parent_adjust_baseline_allocation(&self, baseline: &mut i32) {
779 unsafe {
780 let data = Self::type_data();
781 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
782 let f = (*parent_class)
783 .adjust_baseline_allocation
784 .expect("No parent class impl for \"adjust_baseline_allocation\"");
785 f(
786 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
787 baseline,
788 )
789 }
790 }
791 fn parent_adjust_baseline_request(
792 &self,
793
794 minimum_baseline: &mut i32,
795 natural_baseline: &mut i32,
796 ) {
797 unsafe {
798 let data = Self::type_data();
799 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
800 let f = (*parent_class)
801 .adjust_baseline_request
802 .expect("No parent class impl for \"adjust_baseline_request\"");
803 f(
804 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
805 minimum_baseline,
806 natural_baseline,
807 )
808 }
809 }
810
811 fn parent_preferred_height_and_baseline_for_width(&self, width: i32) -> (i32, i32, i32, i32) {
812 unsafe {
813 let data = Self::type_data();
814 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
815 if let Some(f) = (*parent_class).get_preferred_height_and_baseline_for_width {
816 let mut minimum_height = mem::MaybeUninit::uninit();
817 let mut natural_height = mem::MaybeUninit::uninit();
818 let mut minimum_baseline = -1;
819 let mut natural_baseline = -1;
820 f(
821 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
822 width,
823 minimum_height.as_mut_ptr(),
824 natural_height.as_mut_ptr(),
825 &mut minimum_baseline,
826 &mut natural_baseline,
827 );
828 (
829 minimum_height.assume_init(),
830 natural_height.assume_init(),
831 minimum_baseline,
832 natural_baseline,
833 )
834 } else {
835 let (minimum, natural) = if width < 0 {
842 self.preferred_height()
843 } else {
844 self.preferred_height_for_width(width)
845 };
846 (minimum, natural, -1, -1)
847 }
848 }
849 }
850
851 fn parent_adjust_size_allocation(
852 &self,
853
854 orientation: Orientation,
855 minimum_size: &mut i32,
856 natural_size: &mut i32,
857 allocated_pos: &mut i32,
858 allocated_size: &mut i32,
859 ) {
860 unsafe {
861 let data = Self::type_data();
862 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
863 let f = (*parent_class)
864 .adjust_size_allocation
865 .expect("No parent class impl for \"adjust_size_allocation\"");
866 f(
867 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
868 orientation.into_glib(),
869 minimum_size,
870 natural_size,
871 allocated_pos,
872 allocated_size,
873 )
874 }
875 }
876 fn parent_adjust_size_request(
877 &self,
878
879 orientation: Orientation,
880 minimum_size: &mut i32,
881 natural_size: &mut i32,
882 ) {
883 unsafe {
884 let data = Self::type_data();
885 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
886 let f = (*parent_class)
887 .adjust_size_request
888 .expect("No parent class impl for \"adjust_size_request\"");
889 f(
890 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
891 orientation.into_glib(),
892 minimum_size as *mut i32,
893 natural_size as *mut i32,
894 )
895 }
896 }
897 fn parent_button_press_event(&self, event: &gdk::EventButton) -> Propagation {
898 unsafe {
899 let data = Self::type_data();
900 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
901 if let Some(f) = (*parent_class).button_press_event {
902 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
903 Propagation::from_glib(f(
904 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
905 ev_glib,
906 ))
907 } else {
908 Propagation::Proceed
909 }
910 }
911 }
912 fn parent_button_release_event(&self, event: &gdk::EventButton) -> Propagation {
913 unsafe {
914 let data = Self::type_data();
915 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
916 if let Some(f) = (*parent_class).button_release_event {
917 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
918 Propagation::from_glib(f(
919 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
920 ev_glib,
921 ))
922 } else {
923 Propagation::Proceed
924 }
925 }
926 }
927 fn parent_can_activate_accel(&self, signal_id: SignalId) -> bool {
928 unsafe {
929 let data = Self::type_data();
930 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
931 if let Some(f) = (*parent_class).can_activate_accel {
932 from_glib(f(
933 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
934 signal_id.into_glib(),
935 ))
936 } else {
937 false
938 }
939 }
940 }
941 fn parent_child_notify(&self, child_property: &glib::ParamSpec) {
942 unsafe {
943 let data = Self::type_data();
944 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
945 if let Some(f) = (*parent_class).child_notify {
946 let pspec_glib = glib::translate::mut_override(child_property.to_glib_none().0);
947 f(
948 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
949 pspec_glib,
950 )
951 }
952 }
953 }
954 fn parent_composited_changed(&self) {
955 unsafe {
956 let data = Self::type_data();
957 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
958 if let Some(f) = (*parent_class).composited_changed {
959 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0)
960 }
961 }
962 }
963 fn parent_compute_expand(&self, hexpand: &mut bool, vexpand: &mut bool) {
964 unsafe {
965 let data = Self::type_data();
966 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
967 let widget = self.obj();
968 let widget = widget.unsafe_cast_ref::<Widget>();
969 if let Some(f) = (*parent_class).compute_expand {
970 let mut hexpand_glib = hexpand.into_glib();
971 let mut vexpand_glib = vexpand.into_glib();
972 f(
973 widget.to_glib_none().0,
974 &mut hexpand_glib,
975 &mut vexpand_glib,
976 );
977 *hexpand = from_glib(hexpand_glib);
978 *vexpand = from_glib(vexpand_glib);
979 }
980 }
981 }
982 fn parent_configure_event(&self, event: &gdk::EventConfigure) -> Propagation {
983 unsafe {
984 let data = Self::type_data();
985 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
986 if let Some(f) = (*parent_class).configure_event {
987 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
988 Propagation::from_glib(f(
989 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
990 ev_glib,
991 ))
992 } else {
993 Propagation::Proceed
994 }
995 }
996 }
997 fn parent_window_state_event(&self, event: &gdk::EventWindowState) -> Propagation {
998 unsafe {
999 let data = Self::type_data();
1000 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1001 if let Some(f) = (*parent_class).window_state_event {
1002 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
1003 Propagation::from_glib(f(
1004 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1005 ev_glib,
1006 ))
1007 } else {
1008 Propagation::Proceed
1009 }
1010 }
1011 }
1012 fn parent_damage_event(&self, event: &gdk::EventExpose) -> Propagation {
1013 unsafe {
1014 let data = Self::type_data();
1015 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1016 if let Some(f) = (*parent_class).damage_event {
1017 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
1018 Propagation::from_glib(f(
1019 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1020 ev_glib,
1021 ))
1022 } else {
1023 Propagation::Proceed
1024 }
1025 }
1026 }
1027 fn parent_delete_event(&self, event: &gdk::Event) -> Propagation {
1028 unsafe {
1029 let data = Self::type_data();
1030 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1031 if let Some(f) = (*parent_class).delete_event {
1032 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
1033 Propagation::from_glib(f(
1034 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1035 ev_glib,
1036 ))
1037 } else {
1038 Propagation::Proceed
1039 }
1040 }
1041 }
1042 fn parent_destroy(&self) {
1043 unsafe {
1044 let data = Self::type_data();
1045 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1046 if let Some(f) = (*parent_class).destroy {
1047 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0)
1048 }
1049 }
1050 }
1051 fn parent_destroy_event(&self, event: &gdk::Event) -> Propagation {
1052 unsafe {
1053 let data = Self::type_data();
1054 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1055 if let Some(f) = (*parent_class).destroy_event {
1056 let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
1057 Propagation::from_glib(f(
1058 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1059 ev_glib,
1060 ))
1061 } else {
1062 Propagation::Proceed
1063 }
1064 }
1065 }
1066 fn parent_direction_changed(&self, previous_direction: TextDirection) {
1067 unsafe {
1068 let data = Self::type_data();
1069 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1070 if let Some(f) = (*parent_class).direction_changed {
1071 f(
1072 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1073 previous_direction.into_glib(),
1074 )
1075 }
1076 }
1077 }
1078 fn parent_dispatch_child_properties_changed(&self, pspecs: &[glib::ParamSpec]) {
1079 unsafe {
1080 let data = Self::type_data();
1081 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1082 if let Some(f) = (*parent_class).dispatch_child_properties_changed {
1083 let mut pspecs_array = pspecs
1084 .iter()
1085 .map(|p| p.to_glib_none().0)
1086 .collect::<Vec<_>>();
1087 let pspecs_ptr = pspecs_array.as_mut_ptr();
1088 f(
1089 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1090 pspecs.len() as u32,
1091 pspecs_ptr,
1092 )
1093 }
1094 }
1095 }
1096 fn parent_drag_begin(&self, context: &gdk::DragContext) {
1097 unsafe {
1098 let data = Self::type_data();
1099 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1100 if let Some(f) = (*parent_class).drag_begin {
1101 f(
1102 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1103 context.to_glib_none().0,
1104 )
1105 }
1106 }
1107 }
1108 fn parent_drag_data_delete(&self, context: &gdk::DragContext) {
1109 unsafe {
1110 let data = Self::type_data();
1111 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1112 if let Some(f) = (*parent_class).drag_data_delete {
1113 f(
1114 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1115 context.to_glib_none().0,
1116 )
1117 }
1118 }
1119 }
1120 fn parent_drag_data_get(
1121 &self,
1122
1123 context: &gdk::DragContext,
1124 selection_data: &SelectionData,
1125 info: u32,
1126 time: u32,
1127 ) {
1128 unsafe {
1129 let data = Self::type_data();
1130 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1131 if let Some(f) = (*parent_class).drag_data_get {
1132 let selection_mut = glib::translate::mut_override(selection_data.to_glib_none().0);
1133 f(
1134 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1135 context.to_glib_none().0,
1136 selection_mut,
1137 info,
1138 time,
1139 )
1140 }
1141 }
1142 }
1143 fn parent_drag_data_received(
1144 &self,
1145
1146 context: &gdk::DragContext,
1147 x: i32,
1148 y: i32,
1149 selection_data: &SelectionData,
1150 info: u32,
1151 time: u32,
1152 ) {
1153 unsafe {
1154 let data = Self::type_data();
1155 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1156 if let Some(f) = (*parent_class).drag_data_received {
1157 let selection_mut = glib::translate::mut_override(selection_data.to_glib_none().0);
1158 f(
1159 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1160 context.to_glib_none().0,
1161 x,
1162 y,
1163 selection_mut,
1164 info,
1165 time,
1166 )
1167 }
1168 }
1169 }
1170 fn parent_drag_drop(
1171 &self,
1172 context: &gdk::DragContext,
1173 x: i32,
1174 y: i32,
1175 time: u32,
1176 ) -> Propagation {
1177 unsafe {
1178 let data = Self::type_data();
1179 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1180 if let Some(f) = (*parent_class).drag_drop {
1181 Propagation::from_glib(f(
1182 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1183 context.to_glib_none().0,
1184 x,
1185 y,
1186 time,
1187 ))
1188 } else {
1189 Propagation::Proceed
1190 }
1191 }
1192 }
1193 fn parent_drag_end(&self, context: &gdk::DragContext) {
1194 unsafe {
1195 let data = Self::type_data();
1196 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1197 if let Some(f) = (*parent_class).drag_end {
1198 f(
1199 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1200 context.to_glib_none().0,
1201 )
1202 }
1203 }
1204 }
1205 fn parent_drag_failed(&self, context: &gdk::DragContext, result: DragResult) -> Propagation {
1206 unsafe {
1207 let data = Self::type_data();
1208 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1209 if let Some(f) = (*parent_class).drag_failed {
1210 Propagation::from_glib(f(
1211 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1212 context.to_glib_none().0,
1213 result.into_glib(),
1214 ))
1215 } else {
1216 Propagation::Proceed
1217 }
1218 }
1219 }
1220 fn parent_drag_leave(&self, context: &gdk::DragContext, time: u32) {
1221 unsafe {
1222 let data = Self::type_data();
1223 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1224 if let Some(f) = (*parent_class).drag_leave {
1225 f(
1226 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1227 context.to_glib_none().0,
1228 time,
1229 )
1230 }
1231 }
1232 }
1233 fn parent_drag_motion(
1234 &self,
1235 context: &gdk::DragContext,
1236 x: i32,
1237 y: i32,
1238 time: u32,
1239 ) -> Propagation {
1240 unsafe {
1241 let data = Self::type_data();
1242 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1243 if let Some(f) = (*parent_class).drag_motion {
1244 Propagation::from_glib(f(
1245 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1246 context.to_glib_none().0,
1247 x,
1248 y,
1249 time,
1250 ))
1251 } else {
1252 Propagation::Proceed
1253 }
1254 }
1255 }
1256 fn parent_draw(&self, cr: &cairo::Context) -> Propagation {
1257 unsafe {
1258 let data = Self::type_data();
1259 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1260 if let Some(f) = (*parent_class).draw {
1261 Propagation::from_glib(f(
1262 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1263 cr.to_glib_none().0,
1264 ))
1265 } else {
1266 Propagation::Proceed
1267 }
1268 }
1269 }
1270 fn parent_request_mode(&self) -> SizeRequestMode {
1271 unsafe {
1272 let data = Self::type_data();
1273 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1274 let f = (*parent_class).get_request_mode.unwrap();
1275 from_glib(f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0))
1276 }
1277 }
1278 fn parent_preferred_width(&self) -> (i32, i32) {
1279 unsafe {
1280 let data = Self::type_data();
1281 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1282 let f = (*parent_class).get_preferred_width.unwrap();
1283
1284 let mut minimum_size = mem::MaybeUninit::uninit();
1285 let mut natural_size = mem::MaybeUninit::uninit();
1286 f(
1287 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1288 minimum_size.as_mut_ptr(),
1289 natural_size.as_mut_ptr(),
1290 );
1291 (minimum_size.assume_init(), natural_size.assume_init())
1292 }
1293 }
1294 fn parent_preferred_width_for_height(&self, height: i32) -> (i32, i32) {
1295 unsafe {
1296 let data = Self::type_data();
1297 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1298 let f = (*parent_class).get_preferred_width_for_height.unwrap();
1299
1300 let mut minimum_size = mem::MaybeUninit::uninit();
1301 let mut natural_size = mem::MaybeUninit::uninit();
1302 f(
1303 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1304 height,
1305 minimum_size.as_mut_ptr(),
1306 natural_size.as_mut_ptr(),
1307 );
1308 (minimum_size.assume_init(), natural_size.assume_init())
1309 }
1310 }
1311 fn parent_preferred_height(&self) -> (i32, i32) {
1312 unsafe {
1313 let data = Self::type_data();
1314 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1315 let f = (*parent_class).get_preferred_height.unwrap();
1316 let mut minimum_size = mem::MaybeUninit::uninit();
1317 let mut natural_size = mem::MaybeUninit::uninit();
1318 f(
1319 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1320 minimum_size.as_mut_ptr(),
1321 natural_size.as_mut_ptr(),
1322 );
1323 (minimum_size.assume_init(), natural_size.assume_init())
1324 }
1325 }
1326 fn parent_preferred_height_for_width(&self, width: i32) -> (i32, i32) {
1327 unsafe {
1328 let data = Self::type_data();
1329 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1330 let f = (*parent_class).get_preferred_height_for_width.unwrap();
1331 let mut minimum_size = mem::MaybeUninit::uninit();
1332 let mut natural_size = mem::MaybeUninit::uninit();
1333 f(
1334 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1335 width,
1336 minimum_size.as_mut_ptr(),
1337 natural_size.as_mut_ptr(),
1338 );
1339 (minimum_size.assume_init(), natural_size.assume_init())
1340 }
1341 }
1342 fn parent_size_allocate(&self, allocation: &Allocation) {
1343 unsafe {
1344 let data = Self::type_data();
1345 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1346 let f = (*parent_class)
1347 .size_allocate
1348 .expect("No parent class impl for \"size_allocate\"");
1349 f(
1350 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1351 mut_override(allocation.to_glib_none().0),
1352 );
1353 }
1354 }
1355 fn parent_realize(&self) {
1356 unsafe {
1357 let data = Self::type_data();
1358 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1359 if let Some(f) = (*parent_class).realize {
1360 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1361 }
1362 }
1363 }
1364 fn parent_unrealize(&self) {
1365 unsafe {
1366 let data = Self::type_data();
1367 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1368 if let Some(f) = (*parent_class).unrealize {
1369 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1370 }
1371 }
1372 }
1373 fn parent_map(&self) {
1374 unsafe {
1375 let data = Self::type_data();
1376 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1377 if let Some(f) = (*parent_class).map {
1378 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1379 }
1380 }
1381 }
1382 fn parent_unmap(&self) {
1383 unsafe {
1384 let data = Self::type_data();
1385 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1386 if let Some(f) = (*parent_class).unmap {
1387 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1388 }
1389 }
1390 }
1391
1392 fn parent_show(&self) {
1393 unsafe {
1394 let data = Self::type_data();
1395 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1396 if let Some(f) = (*parent_class).show {
1397 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1398 }
1399 }
1400 }
1401
1402 fn parent_hide(&self) {
1403 unsafe {
1404 let data = Self::type_data();
1405 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1406 if let Some(f) = (*parent_class).hide {
1407 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1408 }
1409 }
1410 }
1411
1412 fn parent_grab_focus(&self) {
1413 unsafe {
1414 let data = Self::type_data();
1415 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1416 if let Some(f) = (*parent_class).grab_focus {
1417 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1418 }
1419 }
1420 }
1421
1422 fn parent_focus(&self, direction: DirectionType) -> bool {
1423 unsafe {
1424 let data = Self::type_data();
1425 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1426 if let Some(f) = (*parent_class).focus {
1427 from_glib(f(
1428 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1429 direction.into_glib(),
1430 ))
1431 } else {
1432 false
1433 }
1434 }
1435 }
1436
1437 fn parent_motion_notify_event(&self, event: &gdk::EventMotion) -> Propagation {
1438 unsafe {
1439 let data = Self::type_data();
1440 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1441 if let Some(f) = (*parent_class).motion_notify_event {
1442 Propagation::from_glib(f(
1443 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1444 mut_override(event.to_glib_none().0),
1445 ))
1446 } else {
1447 Propagation::Proceed
1448 }
1449 }
1450 }
1451 fn parent_scroll_event(&self, event: &gdk::EventScroll) -> Propagation {
1452 unsafe {
1453 let data = Self::type_data();
1454 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1455 if let Some(f) = (*parent_class).scroll_event {
1456 Propagation::from_glib(f(
1457 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1458 mut_override(event.to_glib_none().0),
1459 ))
1460 } else {
1461 Propagation::Proceed
1462 }
1463 }
1464 }
1465 fn parent_enter_notify_event(&self, event: &gdk::EventCrossing) -> Propagation {
1466 unsafe {
1467 let data = Self::type_data();
1468 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1469 if let Some(f) = (*parent_class).enter_notify_event {
1470 Propagation::from_glib(f(
1471 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1472 mut_override(event.to_glib_none().0),
1473 ))
1474 } else {
1475 Propagation::Proceed
1476 }
1477 }
1478 }
1479 fn parent_leave_notify_event(&self, event: &gdk::EventCrossing) -> Propagation {
1480 unsafe {
1481 let data = Self::type_data();
1482 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1483 if let Some(f) = (*parent_class).leave_notify_event {
1484 Propagation::from_glib(f(
1485 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1486 mut_override(event.to_glib_none().0),
1487 ))
1488 } else {
1489 Propagation::Proceed
1490 }
1491 }
1492 }
1493
1494 fn parent_focus_in_event(&self, event: &gdk::EventFocus) -> Propagation {
1495 unsafe {
1496 let data = Self::type_data();
1497 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1498 if let Some(f) = (*parent_class).focus_in_event {
1499 Propagation::from_glib(f(
1500 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1501 mut_override(event.to_glib_none().0),
1502 ))
1503 } else {
1504 Propagation::Proceed
1505 }
1506 }
1507 }
1508
1509 fn parent_focus_out_event(&self, event: &gdk::EventFocus) -> Propagation {
1510 unsafe {
1511 let data = Self::type_data();
1512 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1513 if let Some(f) = (*parent_class).focus_out_event {
1514 Propagation::from_glib(f(
1515 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1516 mut_override(event.to_glib_none().0),
1517 ))
1518 } else {
1519 Propagation::Proceed
1520 }
1521 }
1522 }
1523
1524 fn parent_key_press_event(&self, event: &gdk::EventKey) -> Propagation {
1525 unsafe {
1526 let data = Self::type_data();
1527 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1528 if let Some(f) = (*parent_class).key_press_event {
1529 Propagation::from_glib(f(
1530 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1531 mut_override(event.to_glib_none().0),
1532 ))
1533 } else {
1534 Propagation::Proceed
1535 }
1536 }
1537 }
1538
1539 fn parent_key_release_event(&self, event: &gdk::EventKey) -> Propagation {
1540 unsafe {
1541 let data = Self::type_data();
1542 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1543 if let Some(f) = (*parent_class).key_release_event {
1544 Propagation::from_glib(f(
1545 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1546 mut_override(event.to_glib_none().0),
1547 ))
1548 } else {
1549 Propagation::Proceed
1550 }
1551 }
1552 }
1553
1554 fn parent_map_event(&self, event: &gdk::Event) -> Propagation {
1555 unsafe {
1556 let data = Self::type_data();
1557 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1558 if let Some(f) = (*parent_class).map_event {
1559 Propagation::from_glib(f(
1560 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1561 mut_override(event.to_glib_none().0),
1562 ))
1563 } else {
1564 Propagation::Proceed
1565 }
1566 }
1567 }
1568
1569 fn parent_unmap_event(&self, event: &gdk::Event) -> Propagation {
1570 unsafe {
1571 let data = Self::type_data();
1572 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1573 if let Some(f) = (*parent_class).unmap_event {
1574 Propagation::from_glib(f(
1575 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1576 mut_override(event.to_glib_none().0),
1577 ))
1578 } else {
1579 Propagation::Proceed
1580 }
1581 }
1582 }
1583
1584 fn parent_show_all(&self) {
1585 unsafe {
1586 let data = Self::type_data();
1587 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1588 if let Some(f) = (*parent_class).show_all {
1589 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1590 }
1591 }
1592 }
1593
1594 fn parent_state_flags_changed(&self, previous_state_flags: StateFlags) {
1595 unsafe {
1596 let data = Self::type_data();
1597 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1598 if let Some(f) = (*parent_class).state_flags_changed {
1599 f(
1600 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1601 previous_state_flags.into_glib(),
1602 );
1603 }
1604 }
1605 }
1606
1607 fn parent_parent_set(&self, previous_parent: Option<&Widget>) {
1608 unsafe {
1609 let data = Self::type_data();
1610 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1611 if let Some(f) = (*parent_class).parent_set {
1612 f(
1613 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1614 previous_parent.to_glib_none().0,
1615 );
1616 }
1617 }
1618 }
1619
1620 fn parent_hierarchy_changed(&self, previous_toplevel: Option<&Widget>) {
1621 unsafe {
1622 let data = Self::type_data();
1623 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1624 if let Some(f) = (*parent_class).hierarchy_changed {
1625 f(
1626 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1627 previous_toplevel.to_glib_none().0,
1628 );
1629 }
1630 }
1631 }
1632
1633 fn parent_grab_notify(&self, was_grabbed: bool) {
1634 unsafe {
1635 let data = Self::type_data();
1636 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1637 if let Some(f) = (*parent_class).grab_notify {
1638 f(
1639 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1640 was_grabbed.into_glib(),
1641 );
1642 }
1643 }
1644 }
1645
1646 fn parent_mnemonic_activate(&self, group_cycling: bool) -> bool {
1647 unsafe {
1648 let data = Self::type_data();
1649 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1650 if let Some(f) = (*parent_class).mnemonic_activate {
1651 from_glib(f(
1652 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1653 group_cycling.into_glib(),
1654 ))
1655 } else {
1656 false
1657 }
1658 }
1659 }
1660
1661 fn parent_move_focus(&self, direction: DirectionType) {
1662 unsafe {
1663 let data = Self::type_data();
1664 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1665 if let Some(f) = (*parent_class).move_focus {
1666 f(
1667 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1668 direction.into_glib(),
1669 );
1670 }
1671 }
1672 }
1673
1674 fn parent_keynav_failed(&self, direction: DirectionType) -> bool {
1675 unsafe {
1676 let data = Self::type_data();
1677 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1678 if let Some(f) = (*parent_class).keynav_failed {
1679 from_glib(f(
1680 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1681 direction.into_glib(),
1682 ))
1683 } else {
1684 false
1685 }
1686 }
1687 }
1688
1689 fn parent_event(&self, event: &gdk::Event) -> Propagation {
1690 unsafe {
1691 let data = Self::type_data();
1692 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1693 if let Some(f) = (*parent_class).event {
1694 Propagation::from_glib(f(
1695 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1696 mut_override(event.to_glib_none().0),
1697 ))
1698 } else {
1699 Propagation::Proceed
1700 }
1701 }
1702 }
1703
1704 fn parent_property_notify_event(&self, event: &gdk::EventProperty) -> Propagation {
1705 unsafe {
1706 let data = Self::type_data();
1707 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1708 if let Some(f) = (*parent_class).property_notify_event {
1709 Propagation::from_glib(f(
1710 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1711 mut_override(event.to_glib_none().0),
1712 ))
1713 } else {
1714 Propagation::Proceed
1715 }
1716 }
1717 }
1718
1719 fn parent_selection_clear_event(&self, event: &gdk::EventSelection) -> Propagation {
1720 unsafe {
1721 let data = Self::type_data();
1722 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1723 if let Some(f) = (*parent_class).selection_clear_event {
1724 Propagation::from_glib(f(
1725 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1726 mut_override(event.to_glib_none().0),
1727 ))
1728 } else {
1729 Propagation::Proceed
1730 }
1731 }
1732 }
1733
1734 fn parent_selection_request_event(&self, event: &gdk::EventSelection) -> Propagation {
1735 unsafe {
1736 let data = Self::type_data();
1737 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1738 if let Some(f) = (*parent_class).selection_request_event {
1739 Propagation::from_glib(f(
1740 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1741 mut_override(event.to_glib_none().0),
1742 ))
1743 } else {
1744 Propagation::Proceed
1745 }
1746 }
1747 }
1748
1749 fn parent_selection_notify_event(&self, event: &gdk::EventSelection) -> Propagation {
1750 unsafe {
1751 let data = Self::type_data();
1752 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1753 if let Some(f) = (*parent_class).selection_notify_event {
1754 Propagation::from_glib(f(
1755 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1756 mut_override(event.to_glib_none().0),
1757 ))
1758 } else {
1759 Propagation::Proceed
1760 }
1761 }
1762 }
1763
1764 fn parent_proximity_in_event(&self, event: &gdk::EventProximity) -> Propagation {
1765 unsafe {
1766 let data = Self::type_data();
1767 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1768 if let Some(f) = (*parent_class).proximity_in_event {
1769 Propagation::from_glib(f(
1770 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1771 mut_override(event.to_glib_none().0),
1772 ))
1773 } else {
1774 Propagation::Proceed
1775 }
1776 }
1777 }
1778
1779 fn parent_proximity_out_event(&self, event: &gdk::EventProximity) -> Propagation {
1780 unsafe {
1781 let data = Self::type_data();
1782 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1783 if let Some(f) = (*parent_class).proximity_out_event {
1784 Propagation::from_glib(f(
1785 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1786 mut_override(event.to_glib_none().0),
1787 ))
1788 } else {
1789 Propagation::Proceed
1790 }
1791 }
1792 }
1793
1794 fn parent_visibility_notify_event(&self, event: &gdk::EventVisibility) -> Propagation {
1795 unsafe {
1796 let data = Self::type_data();
1797 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1798 if let Some(f) = (*parent_class).visibility_notify_event {
1799 Propagation::from_glib(f(
1800 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1801 mut_override(event.to_glib_none().0),
1802 ))
1803 } else {
1804 Propagation::Proceed
1805 }
1806 }
1807 }
1808
1809 fn parent_grab_broken_event(&self, event: &gdk::EventGrabBroken) -> Propagation {
1810 unsafe {
1811 let data = Self::type_data();
1812 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1813 if let Some(f) = (*parent_class).grab_broken_event {
1814 Propagation::from_glib(f(
1815 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1816 mut_override(event.to_glib_none().0),
1817 ))
1818 } else {
1819 Propagation::Proceed
1820 }
1821 }
1822 }
1823
1824 fn parent_touch_event(&self, event: &gdk::EventTouch) -> Propagation {
1825 unsafe {
1826 let data = Self::type_data();
1827 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1828 if let Some(f) = (*parent_class).touch_event {
1829 Propagation::from_glib(f(
1830 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1831 mut_override(event.to_glib_none().0),
1832 ))
1833 } else {
1834 Propagation::Proceed
1835 }
1836 }
1837 }
1838
1839 fn parent_selection_get(&self, selection_data: &SelectionData, info: u32, time: u32) {
1840 unsafe {
1841 let data = Self::type_data();
1842 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1843 if let Some(f) = (*parent_class).selection_get {
1844 f(
1845 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1846 mut_override(selection_data.to_glib_none().0),
1847 info,
1848 time,
1849 );
1850 }
1851 }
1852 }
1853
1854 fn parent_selection_received(&self, selection_data: &SelectionData, time: u32) {
1855 unsafe {
1856 let data = Self::type_data();
1857 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1858 if let Some(f) = (*parent_class).selection_received {
1859 f(
1860 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1861 mut_override(selection_data.to_glib_none().0),
1862 time,
1863 );
1864 }
1865 }
1866 }
1867
1868 fn parent_popup_menu(&self) -> bool {
1869 unsafe {
1870 let data = Self::type_data();
1871 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1872 if let Some(f) = (*parent_class).popup_menu {
1873 from_glib(f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0))
1874 } else {
1875 false
1876 }
1877 }
1878 }
1879
1880 fn parent_show_help(&self, help_type: WidgetHelpType) -> bool {
1881 unsafe {
1882 let data = Self::type_data();
1883 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1884 if let Some(f) = (*parent_class).show_help {
1885 from_glib(f(
1886 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1887 help_type.into_glib(),
1888 ))
1889 } else {
1890 false
1891 }
1892 }
1893 }
1894
1895 fn parent_screen_changed(&self, previous_screen: Option<&gdk::Screen>) {
1896 unsafe {
1897 let data = Self::type_data();
1898 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1899 if let Some(f) = (*parent_class).screen_changed {
1900 f(
1901 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1902 previous_screen.to_glib_none().0,
1903 );
1904 }
1905 }
1906 }
1907
1908 fn parent_query_tooltip(
1909 &self,
1910 x: i32,
1911 y: i32,
1912 keyboard_tooltip: bool,
1913 tooltip: &Tooltip,
1914 ) -> bool {
1915 unsafe {
1916 let data = Self::type_data();
1917 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1918 if let Some(f) = (*parent_class).query_tooltip {
1919 from_glib(f(
1920 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1921 x,
1922 y,
1923 keyboard_tooltip.into_glib(),
1924 tooltip.to_glib_none().0,
1925 ))
1926 } else {
1927 false
1928 }
1929 }
1930 }
1931
1932 fn parent_style_updated(&self) {
1933 unsafe {
1934 let data = Self::type_data();
1935 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1936 if let Some(f) = (*parent_class).style_updated {
1937 f(self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0);
1938 }
1939 }
1940 }
1941
1942 fn parent_queue_draw_region(&self, region: &cairo::Region) {
1943 unsafe {
1944 let data = Self::type_data();
1945 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
1946 if let Some(f) = (*parent_class).queue_draw_region {
1947 f(
1948 self.obj().unsafe_cast_ref::<Widget>().to_glib_none().0,
1949 region.to_glib_none().0,
1950 );
1951 }
1952 }
1953 }
1954}
1955
1956impl<T: WidgetImpl> WidgetImplExt for T {}
1957
1958unsafe impl<T: WidgetImpl> IsSubclassable<T> for Widget {
1959 fn class_init(class: &mut ::glib::Class<Self>) {
1960 Self::parent_class_init::<T>(class);
1961
1962 if !crate::rt::is_initialized() {
1963 panic!("GTK has to be initialized first");
1964 }
1965
1966 let klass = class.as_mut();
1967 klass.adjust_baseline_allocation = Some(widget_adjust_baseline_allocation::<T>);
1968 klass.adjust_baseline_request = Some(widget_adjust_baseline_request::<T>);
1969 klass.adjust_size_allocation = Some(widget_adjust_size_allocation::<T>);
1970 klass.adjust_size_request = Some(widget_adjust_size_request::<T>);
1971 klass.button_press_event = Some(widget_button_press_event::<T>);
1972 klass.button_release_event = Some(widget_button_release_event::<T>);
1973 klass.can_activate_accel = Some(widget_can_activate_accel::<T>);
1974 klass.child_notify = Some(widget_child_notify::<T>);
1975 klass.composited_changed = Some(widget_composited_changed::<T>);
1976 klass.compute_expand = Some(widget_compute_expand::<T>);
1977 klass.configure_event = Some(widget_configure_event::<T>);
1978 klass.damage_event = Some(widget_damage_event::<T>);
1979 klass.delete_event = Some(widget_delete_event::<T>);
1980 klass.destroy = Some(widget_destroy::<T>);
1981 klass.destroy_event = Some(widget_destroy_event::<T>);
1982 klass.direction_changed = Some(widget_direction_changed::<T>);
1983 klass.dispatch_child_properties_changed =
1984 Some(widget_dispatch_child_properties_changed::<T>);
1985 klass.drag_begin = Some(widget_drag_begin::<T>);
1986 klass.drag_data_delete = Some(widget_drag_data_delete::<T>);
1987 klass.drag_data_get = Some(widget_drag_data_get::<T>);
1988 klass.drag_data_received = Some(widget_drag_data_received::<T>);
1989 klass.drag_drop = Some(widget_drag_drop::<T>);
1990 klass.drag_end = Some(widget_drag_end::<T>);
1991 klass.drag_failed = Some(widget_drag_failed::<T>);
1992 klass.drag_leave = Some(widget_drag_leave::<T>);
1993 klass.drag_motion = Some(widget_drag_motion::<T>);
1994 klass.draw = Some(widget_draw::<T>);
1995 klass.enter_notify_event = Some(widget_enter_notify_event::<T>);
1996 klass.event = Some(widget_event::<T>);
1997 klass.focus = Some(widget_focus::<T>);
1998 klass.focus_in_event = Some(widget_focus_in_event::<T>);
1999 klass.focus_out_event = Some(widget_focus_out_event::<T>);
2000 klass.get_preferred_height = Some(widget_get_preferred_height::<T>);
2001 klass.get_preferred_height_for_width = Some(widget_get_preferred_height_for_width::<T>);
2002 klass.get_preferred_width = Some(widget_get_preferred_width::<T>);
2003 klass.get_preferred_width_for_height = Some(widget_get_preferred_width_for_height::<T>);
2004 klass.get_request_mode = Some(widget_get_request_mode::<T>);
2005 klass.grab_broken_event = Some(widget_grab_broken_event::<T>);
2006 klass.grab_focus = Some(widget_grab_focus::<T>);
2007 klass.grab_notify = Some(widget_grab_notify::<T>);
2008 klass.hide = Some(widget_hide::<T>);
2009 klass.hierarchy_changed = Some(widget_hierarchy_changed::<T>);
2010 klass.key_press_event = Some(widget_key_press_event::<T>);
2011 klass.key_release_event = Some(widget_key_release_event::<T>);
2012 klass.keynav_failed = Some(widget_keynav_failed::<T>);
2013 klass.leave_notify_event = Some(widget_leave_notify_event::<T>);
2014 klass.map = Some(widget_map::<T>);
2015 klass.map_event = Some(widget_map_event::<T>);
2016 klass.mnemonic_activate = Some(widget_mnemonic_activate::<T>);
2017 klass.motion_notify_event = Some(widget_motion_notify_event::<T>);
2018 klass.move_focus = Some(widget_move_focus::<T>);
2019 klass.parent_set = Some(widget_parent_set::<T>);
2020 klass.popup_menu = Some(widget_popup_menu::<T>);
2021 klass.property_notify_event = Some(widget_property_notify_event::<T>);
2022 klass.proximity_in_event = Some(widget_proximity_in_event::<T>);
2023 klass.proximity_out_event = Some(widget_proximity_out_event::<T>);
2024 klass.query_tooltip = Some(widget_query_tooltip::<T>);
2025 klass.queue_draw_region = Some(widget_queue_draw_region::<T>);
2026 klass.realize = Some(widget_realize::<T>);
2027 klass.screen_changed = Some(widget_screen_changed::<T>);
2028 klass.scroll_event = Some(widget_scroll_event::<T>);
2029 klass.selection_clear_event = Some(widget_selection_clear_event::<T>);
2030 klass.selection_get = Some(widget_selection_get::<T>);
2031 klass.selection_notify_event = Some(widget_selection_notify_event::<T>);
2032 klass.selection_received = Some(widget_selection_received::<T>);
2033 klass.selection_request_event = Some(widget_selection_request_event::<T>);
2034 klass.show = Some(widget_show::<T>);
2035 klass.show_all = Some(widget_show_all::<T>);
2036 klass.show_help = Some(widget_show_help::<T>);
2037 klass.size_allocate = Some(widget_size_allocate::<T>);
2038 klass.state_flags_changed = Some(widget_state_flags_changed::<T>);
2039 klass.style_updated = Some(widget_style_updated::<T>);
2040 klass.touch_event = Some(widget_touch_event::<T>);
2041 klass.unmap = Some(widget_unmap::<T>);
2042 klass.unmap_event = Some(widget_unmap_event::<T>);
2043 klass.unrealize = Some(widget_unrealize::<T>);
2044 klass.visibility_notify_event = Some(widget_visibility_notify_event::<T>);
2045 klass.window_state_event = Some(widget_window_state_event::<T>);
2046 }
2047}
2048
2049unsafe extern "C" fn widget_adjust_baseline_allocation<T: WidgetImpl>(
2050 ptr: *mut ffi::GtkWidget,
2051 baseptr: *mut i32,
2052) {
2053 unsafe {
2054 let instance = &*(ptr as *mut T::Instance);
2055 let imp = instance.imp();
2056
2057 imp.adjust_baseline_allocation(&mut *baseptr)
2058 }
2059}
2060
2061unsafe extern "C" fn widget_adjust_baseline_request<T: WidgetImpl>(
2062 ptr: *mut ffi::GtkWidget,
2063 minptr: *mut i32,
2064 natptr: *mut i32,
2065) {
2066 unsafe {
2067 let instance = &*(ptr as *mut T::Instance);
2068 let imp = instance.imp();
2069
2070 imp.adjust_baseline_request(&mut *minptr, &mut *natptr)
2071 }
2072}
2073
2074unsafe extern "C" fn widget_adjust_size_allocation<T: WidgetImpl>(
2075 ptr: *mut ffi::GtkWidget,
2076 orientation: ffi::GtkOrientation,
2077 minptr: *mut i32,
2078 natptr: *mut i32,
2079 posptr: *mut i32,
2080 sizeptr: *mut i32,
2081) {
2082 unsafe {
2083 let instance = &*(ptr as *mut T::Instance);
2084 let imp = instance.imp();
2085 let wrap_orientation: Orientation = from_glib(orientation);
2086
2087 imp.adjust_size_allocation(
2088 wrap_orientation,
2089 &mut *minptr,
2090 &mut *natptr,
2091 &mut *posptr,
2092 &mut *sizeptr,
2093 )
2094 }
2095}
2096
2097unsafe extern "C" fn widget_adjust_size_request<T: WidgetImpl>(
2098 ptr: *mut ffi::GtkWidget,
2099 orientation: ffi::GtkOrientation,
2100 minptr: *mut i32,
2101 natptr: *mut i32,
2102) {
2103 unsafe {
2104 let instance = &*(ptr as *mut T::Instance);
2105 let imp = instance.imp();
2106 let wrap_orientation: Orientation = from_glib(orientation);
2107
2108 imp.adjust_size_request(wrap_orientation, &mut *minptr, &mut *natptr)
2109 }
2110}
2111
2112unsafe extern "C" fn widget_button_press_event<T: WidgetImpl>(
2113 ptr: *mut ffi::GtkWidget,
2114 btnptr: *mut gdk::ffi::GdkEventButton,
2115) -> glib::ffi::gboolean {
2116 unsafe {
2117 let instance = &*(ptr as *mut T::Instance);
2118 let imp = instance.imp();
2119 let evwrap: Borrowed<gdk::EventButton> = from_glib_borrow(btnptr);
2120
2121 imp.button_press_event(&evwrap).into_glib()
2122 }
2123}
2124
2125unsafe extern "C" fn widget_button_release_event<T: WidgetImpl>(
2126 ptr: *mut ffi::GtkWidget,
2127 btnptr: *mut gdk::ffi::GdkEventButton,
2128) -> glib::ffi::gboolean {
2129 unsafe {
2130 let instance = &*(ptr as *mut T::Instance);
2131 let imp = instance.imp();
2132 let evwrap: Borrowed<gdk::EventButton> = from_glib_borrow(btnptr);
2133
2134 imp.button_release_event(&evwrap).into_glib()
2135 }
2136}
2137
2138unsafe extern "C" fn widget_can_activate_accel<T: WidgetImpl>(
2139 ptr: *mut ffi::GtkWidget,
2140 signal_id: u32,
2141) -> glib::ffi::gboolean {
2142 unsafe {
2143 let instance = &*(ptr as *mut T::Instance);
2144 let imp = instance.imp();
2145
2146 if let Some(signal_id) = NonZeroU32::new(signal_id).map(|nz| SignalId::new(nz)) {
2147 imp.can_activate_accel(signal_id).into_glib()
2148 } else {
2149 let data = T::type_data();
2153 let parent_class = data.as_ref().parent_class() as *mut ffi::GtkWidgetClass;
2154 if let Some(f) = (*parent_class).can_activate_accel {
2155 f(ptr, signal_id)
2156 } else {
2157 false.into_glib()
2158 }
2159 }
2160 }
2161}
2162
2163unsafe extern "C" fn widget_child_notify<T: WidgetImpl>(
2164 ptr: *mut ffi::GtkWidget,
2165 paramptr: *mut glib::gobject_ffi::GParamSpec,
2166) {
2167 unsafe {
2168 let instance = &*(ptr as *mut T::Instance);
2169 let imp = instance.imp();
2170 let paramwrap: Borrowed<glib::ParamSpec> = from_glib_borrow(paramptr);
2171
2172 imp.child_notify(¶mwrap)
2173 }
2174}
2175
2176unsafe extern "C" fn widget_composited_changed<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2177 unsafe {
2178 let instance = &*(ptr as *mut T::Instance);
2179 let imp = instance.imp();
2180
2181 imp.composited_changed()
2182 }
2183}
2184
2185unsafe extern "C" fn widget_compute_expand<T: WidgetImpl>(
2186 ptr: *mut ffi::GtkWidget,
2187 hexpand_ptr: *mut glib::ffi::gboolean,
2188 vexpand_ptr: *mut glib::ffi::gboolean,
2189) {
2190 unsafe {
2191 let instance = &*(ptr as *mut T::Instance);
2192 let imp = instance.imp();
2193
2194 let widget = imp.obj();
2195 let widget = widget.unsafe_cast_ref::<Widget>();
2196 let mut hexpand: bool = if widget.is_hexpand_set() {
2197 widget.hexpands()
2198 } else {
2199 from_glib(*hexpand_ptr)
2200 };
2201 let mut vexpand: bool = if widget.is_vexpand_set() {
2202 widget.vexpands()
2203 } else {
2204 from_glib(*vexpand_ptr)
2205 };
2206
2207 imp.compute_expand(&mut hexpand, &mut vexpand);
2208 *hexpand_ptr = hexpand.into_glib();
2209 *vexpand_ptr = vexpand.into_glib();
2210 }
2211}
2212
2213unsafe extern "C" fn widget_configure_event<T: WidgetImpl>(
2214 ptr: *mut ffi::GtkWidget,
2215 confptr: *mut gdk::ffi::GdkEventConfigure,
2216) -> glib::ffi::gboolean {
2217 unsafe {
2218 let instance = &*(ptr as *mut T::Instance);
2219 let imp = instance.imp();
2220 let evwrap: Borrowed<gdk::EventConfigure> = from_glib_borrow(confptr);
2221
2222 imp.configure_event(&evwrap).into_glib()
2223 }
2224}
2225
2226unsafe extern "C" fn widget_window_state_event<T: WidgetImpl>(
2227 ptr: *mut ffi::GtkWidget,
2228 winstateptr: *mut gdk::ffi::GdkEventWindowState,
2229) -> glib::ffi::gboolean {
2230 unsafe {
2231 let instance = &*(ptr as *mut T::Instance);
2232 let imp = instance.imp();
2233 let evwrap: Borrowed<gdk::EventWindowState> = from_glib_borrow(winstateptr);
2234
2235 imp.window_state_event(&evwrap).into_glib()
2236 }
2237}
2238
2239unsafe extern "C" fn widget_damage_event<T: WidgetImpl>(
2240 ptr: *mut ffi::GtkWidget,
2241 exposeptr: *mut gdk::ffi::GdkEventExpose,
2242) -> glib::ffi::gboolean {
2243 unsafe {
2244 let instance = &*(ptr as *mut T::Instance);
2245 let imp = instance.imp();
2246 let evwrap: Borrowed<gdk::EventExpose> = from_glib_borrow(exposeptr);
2247
2248 imp.damage_event(&evwrap).into_glib()
2249 }
2250}
2251
2252unsafe extern "C" fn widget_delete_event<T: WidgetImpl>(
2253 ptr: *mut ffi::GtkWidget,
2254 anyptr: *mut gdk::ffi::GdkEventAny,
2255) -> glib::ffi::gboolean {
2256 unsafe {
2257 let instance = &*(ptr as *mut T::Instance);
2258 let imp = instance.imp();
2259 let evwrap: Borrowed<gdk::Event> = from_glib_borrow(anyptr);
2260
2261 imp.delete_event(&evwrap).into_glib()
2262 }
2263}
2264
2265unsafe extern "C" fn widget_destroy<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2266 unsafe {
2267 let instance = &*(ptr as *mut T::Instance);
2268 let imp = instance.imp();
2269
2270 imp.destroy()
2271 }
2272}
2273
2274unsafe extern "C" fn widget_destroy_event<T: WidgetImpl>(
2275 ptr: *mut ffi::GtkWidget,
2276 anyptr: *mut gdk::ffi::GdkEventAny,
2277) -> glib::ffi::gboolean {
2278 unsafe {
2279 let instance = &*(ptr as *mut T::Instance);
2280 let imp = instance.imp();
2281 let evwrap: Borrowed<gdk::Event> = from_glib_borrow(anyptr);
2282
2283 imp.destroy_event(&evwrap).into_glib()
2284 }
2285}
2286
2287unsafe extern "C" fn widget_direction_changed<T: WidgetImpl>(
2288 ptr: *mut ffi::GtkWidget,
2289 directnptr: ffi::GtkTextDirection,
2290) {
2291 unsafe {
2292 let instance = &*(ptr as *mut T::Instance);
2293 let imp = instance.imp();
2294 let dirwrap: TextDirection = from_glib(directnptr);
2295
2296 imp.direction_changed(dirwrap)
2297 }
2298}
2299
2300unsafe extern "C" fn widget_dispatch_child_properties_changed<T: WidgetImpl>(
2301 ptr: *mut ffi::GtkWidget,
2302 n_pspec_ptr: u32,
2303 pspecsptr: *mut *mut glib::gobject_ffi::GParamSpec,
2304) {
2305 unsafe {
2306 let instance = &*(ptr as *mut T::Instance);
2307 let imp = instance.imp();
2308 let pspecs: Vec<glib::ParamSpec> =
2309 FromGlibContainer::from_glib_none_num(pspecsptr, n_pspec_ptr as usize);
2310
2311 imp.dispatch_child_properties_changed(&pspecs)
2312 }
2313}
2314
2315unsafe extern "C" fn widget_drag_begin<T: WidgetImpl>(
2316 ptr: *mut ffi::GtkWidget,
2317 ctxptr: *mut gdk::ffi::GdkDragContext,
2318) {
2319 unsafe {
2320 let instance = &*(ptr as *mut T::Instance);
2321 let imp = instance.imp();
2322 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2323
2324 imp.drag_begin(&context)
2325 }
2326}
2327
2328unsafe extern "C" fn widget_drag_data_delete<T: WidgetImpl>(
2329 ptr: *mut ffi::GtkWidget,
2330 ctxptr: *mut gdk::ffi::GdkDragContext,
2331) {
2332 unsafe {
2333 let instance = &*(ptr as *mut T::Instance);
2334 let imp = instance.imp();
2335 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2336
2337 imp.drag_data_delete(&context)
2338 }
2339}
2340
2341unsafe extern "C" fn widget_drag_data_get<T: WidgetImpl>(
2342 ptr: *mut ffi::GtkWidget,
2343 ctxptr: *mut gdk::ffi::GdkDragContext,
2344 selectptr: *mut ffi::GtkSelectionData,
2345 info: u32,
2346 time: u32,
2347) {
2348 unsafe {
2349 let instance = &*(ptr as *mut T::Instance);
2350 let imp = instance.imp();
2351 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2352 let selection_data: Borrowed<SelectionData> = from_glib_borrow(selectptr);
2353
2354 imp.drag_data_get(&context, &selection_data, info, time)
2355 }
2356}
2357
2358unsafe extern "C" fn widget_drag_data_received<T: WidgetImpl>(
2359 ptr: *mut ffi::GtkWidget,
2360 ctxptr: *mut gdk::ffi::GdkDragContext,
2361 x: i32,
2362 y: i32,
2363 selectptr: *mut ffi::GtkSelectionData,
2364 info: u32,
2365 time: u32,
2366) {
2367 unsafe {
2368 let instance = &*(ptr as *mut T::Instance);
2369 let imp = instance.imp();
2370 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2371 let selection_data: Borrowed<SelectionData> = from_glib_borrow(selectptr);
2372
2373 imp.drag_data_received(&context, x, y, &selection_data, info, time)
2374 }
2375}
2376
2377unsafe extern "C" fn widget_drag_drop<T: WidgetImpl>(
2378 ptr: *mut ffi::GtkWidget,
2379 ctxptr: *mut gdk::ffi::GdkDragContext,
2380 x: i32,
2381 y: i32,
2382 time: u32,
2383) -> glib::ffi::gboolean {
2384 unsafe {
2385 let instance = &*(ptr as *mut T::Instance);
2386 let imp = instance.imp();
2387 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2388
2389 imp.drag_drop(&context, x, y, time).into_glib()
2390 }
2391}
2392
2393unsafe extern "C" fn widget_drag_end<T: WidgetImpl>(
2394 ptr: *mut ffi::GtkWidget,
2395 ctxptr: *mut gdk::ffi::GdkDragContext,
2396) {
2397 unsafe {
2398 let instance = &*(ptr as *mut T::Instance);
2399 let imp = instance.imp();
2400 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2401
2402 imp.drag_end(&context)
2403 }
2404}
2405
2406unsafe extern "C" fn widget_drag_failed<T: WidgetImpl>(
2407 ptr: *mut ffi::GtkWidget,
2408 ctxptr: *mut gdk::ffi::GdkDragContext,
2409 resultptr: ffi::GtkDragResult,
2410) -> glib::ffi::gboolean {
2411 unsafe {
2412 let instance = &*(ptr as *mut T::Instance);
2413 let imp = instance.imp();
2414 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2415 let result: DragResult = from_glib(resultptr);
2416
2417 imp.drag_failed(&context, result).into_glib()
2418 }
2419}
2420
2421unsafe extern "C" fn widget_drag_leave<T: WidgetImpl>(
2422 ptr: *mut ffi::GtkWidget,
2423 ctxptr: *mut gdk::ffi::GdkDragContext,
2424 time: u32,
2425) {
2426 unsafe {
2427 let instance = &*(ptr as *mut T::Instance);
2428 let imp = instance.imp();
2429 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2430
2431 imp.drag_leave(&context, time)
2432 }
2433}
2434
2435unsafe extern "C" fn widget_drag_motion<T: WidgetImpl>(
2436 ptr: *mut ffi::GtkWidget,
2437 ctxptr: *mut gdk::ffi::GdkDragContext,
2438 x: i32,
2439 y: i32,
2440 time: u32,
2441) -> glib::ffi::gboolean {
2442 unsafe {
2443 let instance = &*(ptr as *mut T::Instance);
2444 let imp = instance.imp();
2445 let context: Borrowed<gdk::DragContext> = from_glib_borrow(ctxptr);
2446
2447 imp.drag_motion(&context, x, y, time).into_glib()
2448 }
2449}
2450
2451unsafe extern "C" fn widget_draw<T: WidgetImpl>(
2452 ptr: *mut ffi::GtkWidget,
2453 cr_ptr: *mut cairo::ffi::cairo_t,
2454) -> glib::ffi::gboolean {
2455 unsafe {
2456 let instance = &*(ptr as *mut T::Instance);
2457 let imp = instance.imp();
2458 let cr: Borrowed<cairo::Context> = from_glib_borrow(cr_ptr);
2459
2460 imp.draw(&cr).into_glib()
2461 }
2462}
2463
2464unsafe extern "C" fn widget_get_request_mode<T: WidgetImpl>(
2465 ptr: *mut ffi::GtkWidget,
2466) -> ffi::GtkSizeRequestMode {
2467 unsafe {
2468 let instance = &*(ptr as *mut T::Instance);
2469 let imp = instance.imp();
2470
2471 imp.request_mode().into_glib()
2472 }
2473}
2474
2475unsafe extern "C" fn widget_get_preferred_height<T: WidgetImpl>(
2476 ptr: *mut ffi::GtkWidget,
2477 minptr: *mut c_int,
2478 natptr: *mut c_int,
2479) {
2480 unsafe {
2481 let instance = &*(ptr as *mut T::Instance);
2482 let imp = instance.imp();
2483
2484 let (min_size, nat_size) = imp.preferred_height();
2485 if !minptr.is_null() {
2486 *minptr = min_size;
2487 }
2488 if !natptr.is_null() {
2489 *natptr = nat_size;
2490 }
2491 }
2492}
2493
2494unsafe extern "C" fn widget_get_preferred_width_for_height<T: WidgetImpl>(
2495 ptr: *mut ffi::GtkWidget,
2496 height: c_int,
2497 min_width_ptr: *mut c_int,
2498 nat_width_ptr: *mut c_int,
2499) {
2500 unsafe {
2501 let instance = &*(ptr as *mut T::Instance);
2502 let imp = instance.imp();
2503
2504 let (min_width, nat_width) = imp.preferred_width_for_height(height);
2505 if !min_width_ptr.is_null() {
2506 *min_width_ptr = min_width;
2507 }
2508 if !nat_width_ptr.is_null() {
2509 *nat_width_ptr = nat_width;
2510 }
2511 }
2512}
2513
2514unsafe extern "C" fn widget_get_preferred_width<T: WidgetImpl>(
2515 ptr: *mut ffi::GtkWidget,
2516 minptr: *mut c_int,
2517 natptr: *mut c_int,
2518) {
2519 unsafe {
2520 let instance = &*(ptr as *mut T::Instance);
2521 let imp = instance.imp();
2522 let (min_size, nat_size) = imp.preferred_width();
2523 if !minptr.is_null() {
2524 *minptr = min_size;
2525 }
2526 if !natptr.is_null() {
2527 *natptr = nat_size;
2528 }
2529 }
2530}
2531
2532unsafe extern "C" fn widget_get_preferred_height_for_width<T: WidgetImpl>(
2533 ptr: *mut ffi::GtkWidget,
2534 width: c_int,
2535 min_height_ptr: *mut c_int,
2536 nat_height_ptr: *mut c_int,
2537) {
2538 unsafe {
2539 let instance = &*(ptr as *mut T::Instance);
2540 let imp = instance.imp();
2541
2542 let (min_height, nat_height) = imp.preferred_height_for_width(width);
2543 if !min_height_ptr.is_null() {
2544 *min_height_ptr = min_height;
2545 }
2546 if !nat_height_ptr.is_null() {
2547 *nat_height_ptr = nat_height;
2548 }
2549 }
2550}
2551
2552unsafe extern "C" fn widget_get_preferred_height_and_baseline_for_width<T: WidgetImpl>(
2553 ptr: *mut ffi::GtkWidget,
2554 width: c_int,
2555 min_height_ptr: *mut c_int,
2556 nat_height_ptr: *mut c_int,
2557 min_baseline_ptr: *mut c_int,
2558 nat_baseline_ptr: *mut c_int,
2559) {
2560 unsafe {
2561 let instance = &*(ptr as *mut T::Instance);
2562 let imp = instance.imp();
2563
2564 let (min_height, nat_height, min_baseline, nat_baseline) =
2565 imp.preferred_height_and_baseline_for_width(width);
2566 if !min_height_ptr.is_null() {
2567 *min_height_ptr = min_height;
2568 }
2569 if !nat_height_ptr.is_null() {
2570 *nat_height_ptr = nat_height;
2571 }
2572 if !min_baseline_ptr.is_null() {
2573 *min_baseline_ptr = min_baseline;
2574 }
2575 if !nat_baseline_ptr.is_null() {
2576 *nat_baseline_ptr = nat_baseline;
2577 }
2578 }
2579}
2580
2581unsafe extern "C" fn widget_size_allocate<T: WidgetImpl>(
2582 ptr: *mut ffi::GtkWidget,
2583 allocation: *mut ffi::GtkAllocation,
2584) {
2585 unsafe {
2586 let instance = &*(ptr as *mut T::Instance);
2587 let imp = instance.imp();
2588 let allocate: &Allocation = &from_glib_none(allocation);
2589
2590 imp.size_allocate(allocate);
2591 }
2592}
2593
2594unsafe extern "C" fn widget_realize<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2595 unsafe {
2596 let instance = &*(ptr as *mut T::Instance);
2597 let imp = instance.imp();
2598
2599 imp.realize();
2600 }
2601}
2602
2603unsafe extern "C" fn widget_unrealize<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2604 unsafe {
2605 let instance = &*(ptr as *mut T::Instance);
2606 let imp = instance.imp();
2607
2608 imp.unrealize();
2609 }
2610}
2611
2612unsafe extern "C" fn widget_map<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2613 unsafe {
2614 let instance = &*(ptr as *mut T::Instance);
2615 let imp = instance.imp();
2616 imp.map();
2617 }
2618}
2619
2620unsafe extern "C" fn widget_unmap<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2621 unsafe {
2622 let instance = &*(ptr as *mut T::Instance);
2623 let imp = instance.imp();
2624 imp.unmap();
2625 }
2626}
2627
2628unsafe extern "C" fn widget_show<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2629 unsafe {
2630 let instance = &*(ptr as *mut T::Instance);
2631 let imp = instance.imp();
2632 imp.show();
2633 }
2634}
2635
2636unsafe extern "C" fn widget_hide<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2637 unsafe {
2638 let instance = &*(ptr as *mut T::Instance);
2639 let imp = instance.imp();
2640 imp.hide();
2641 }
2642}
2643
2644unsafe extern "C" fn widget_grab_focus<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2645 unsafe {
2646 let instance = &*(ptr as *mut T::Instance);
2647 let imp = instance.imp();
2648 imp.grab_focus();
2649 }
2650}
2651
2652unsafe extern "C" fn widget_focus<T: WidgetImpl>(
2653 ptr: *mut ffi::GtkWidget,
2654 direction: ffi::GtkDirectionType,
2655) -> glib::ffi::gboolean {
2656 unsafe {
2657 let instance = &*(ptr as *mut T::Instance);
2658 let imp = instance.imp();
2659 imp.focus(from_glib(direction)).into_glib()
2660 }
2661}
2662
2663unsafe extern "C" fn widget_motion_notify_event<T: WidgetImpl>(
2664 ptr: *mut ffi::GtkWidget,
2665 mptr: *mut gdk::ffi::GdkEventMotion,
2666) -> glib::ffi::gboolean {
2667 unsafe {
2668 let instance = &*(ptr as *mut T::Instance);
2669 let imp = instance.imp();
2670 let event: Borrowed<gdk::EventMotion> = from_glib_borrow(mptr);
2671
2672 imp.motion_notify_event(&event).into_glib()
2673 }
2674}
2675
2676unsafe extern "C" fn widget_scroll_event<T: WidgetImpl>(
2677 ptr: *mut ffi::GtkWidget,
2678 mptr: *mut gdk::ffi::GdkEventScroll,
2679) -> glib::ffi::gboolean {
2680 unsafe {
2681 let instance = &*(ptr as *mut T::Instance);
2682 let imp = instance.imp();
2683 let event: Borrowed<gdk::EventScroll> = from_glib_borrow(mptr);
2684
2685 imp.scroll_event(&event).into_glib()
2686 }
2687}
2688
2689unsafe extern "C" fn widget_enter_notify_event<T: WidgetImpl>(
2690 ptr: *mut ffi::GtkWidget,
2691 mptr: *mut gdk::ffi::GdkEventCrossing,
2692) -> glib::ffi::gboolean {
2693 unsafe {
2694 let instance = &*(ptr as *mut T::Instance);
2695 let imp = instance.imp();
2696 let event: Borrowed<gdk::EventCrossing> = from_glib_borrow(mptr);
2697
2698 imp.enter_notify_event(&event).into_glib()
2699 }
2700}
2701
2702unsafe extern "C" fn widget_leave_notify_event<T: WidgetImpl>(
2703 ptr: *mut ffi::GtkWidget,
2704 mptr: *mut gdk::ffi::GdkEventCrossing,
2705) -> glib::ffi::gboolean {
2706 unsafe {
2707 let instance = &*(ptr as *mut T::Instance);
2708 let imp = instance.imp();
2709 let event: Borrowed<gdk::EventCrossing> = from_glib_borrow(mptr);
2710
2711 imp.leave_notify_event(&event).into_glib()
2712 }
2713}
2714
2715unsafe extern "C" fn widget_focus_in_event<T: WidgetImpl>(
2716 ptr: *mut ffi::GtkWidget,
2717 mptr: *mut gdk::ffi::GdkEventFocus,
2718) -> glib::ffi::gboolean {
2719 unsafe {
2720 let instance = &*(ptr as *mut T::Instance);
2721 let imp = instance.imp();
2722 let event: Borrowed<gdk::EventFocus> = from_glib_borrow(mptr);
2723
2724 imp.focus_in_event(&event).into_glib()
2725 }
2726}
2727
2728unsafe extern "C" fn widget_focus_out_event<T: WidgetImpl>(
2729 ptr: *mut ffi::GtkWidget,
2730 mptr: *mut gdk::ffi::GdkEventFocus,
2731) -> glib::ffi::gboolean {
2732 unsafe {
2733 let instance = &*(ptr as *mut T::Instance);
2734 let imp = instance.imp();
2735 let event: Borrowed<gdk::EventFocus> = from_glib_borrow(mptr);
2736
2737 imp.focus_out_event(&event).into_glib()
2738 }
2739}
2740
2741unsafe extern "C" fn widget_key_press_event<T: WidgetImpl>(
2742 ptr: *mut ffi::GtkWidget,
2743 mptr: *mut gdk::ffi::GdkEventKey,
2744) -> glib::ffi::gboolean {
2745 unsafe {
2746 let instance = &*(ptr as *mut T::Instance);
2747 let imp = instance.imp();
2748 let event: Borrowed<gdk::EventKey> = from_glib_borrow(mptr);
2749
2750 imp.key_press_event(&event).into_glib()
2751 }
2752}
2753
2754unsafe extern "C" fn widget_key_release_event<T: WidgetImpl>(
2755 ptr: *mut ffi::GtkWidget,
2756 mptr: *mut gdk::ffi::GdkEventKey,
2757) -> glib::ffi::gboolean {
2758 unsafe {
2759 let instance = &*(ptr as *mut T::Instance);
2760 let imp = instance.imp();
2761 let event: Borrowed<gdk::EventKey> = from_glib_borrow(mptr);
2762
2763 imp.key_release_event(&event).into_glib()
2764 }
2765}
2766
2767unsafe extern "C" fn widget_map_event<T: WidgetImpl>(
2768 ptr: *mut ffi::GtkWidget,
2769 anyptr: *mut gdk::ffi::GdkEventAny,
2770) -> glib::ffi::gboolean {
2771 unsafe {
2772 let instance = &*(ptr as *mut T::Instance);
2773 let imp = instance.imp();
2774 let evwrap: Borrowed<gdk::Event> = from_glib_borrow(anyptr);
2775
2776 imp.map_event(&evwrap).into_glib()
2777 }
2778}
2779
2780unsafe extern "C" fn widget_unmap_event<T: WidgetImpl>(
2781 ptr: *mut ffi::GtkWidget,
2782 anyptr: *mut gdk::ffi::GdkEventAny,
2783) -> glib::ffi::gboolean {
2784 unsafe {
2785 let instance = &*(ptr as *mut T::Instance);
2786 let imp = instance.imp();
2787 let evwrap: Borrowed<gdk::Event> = from_glib_borrow(anyptr);
2788
2789 imp.unmap_event(&evwrap).into_glib()
2790 }
2791}
2792
2793unsafe extern "C" fn widget_show_all<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2794 unsafe {
2795 let instance = &*(ptr as *mut T::Instance);
2796 let imp = instance.imp();
2797 imp.show_all();
2798 }
2799}
2800
2801unsafe extern "C" fn widget_style_updated<T: WidgetImpl>(ptr: *mut ffi::GtkWidget) {
2802 unsafe {
2803 let instance = &*(ptr as *mut T::Instance);
2804 let imp = instance.imp();
2805 imp.style_updated();
2806 }
2807}
2808
2809unsafe extern "C" fn widget_state_flags_changed<T: WidgetImpl>(
2810 ptr: *mut ffi::GtkWidget,
2811 flags: ffi::GtkStateFlags,
2812) {
2813 unsafe {
2814 let instance = &*(ptr as *mut T::Instance);
2815 let imp = instance.imp();
2816 imp.state_flags_changed(from_glib(flags));
2817 }
2818}
2819
2820unsafe extern "C" fn widget_parent_set<T: WidgetImpl>(
2821 ptr: *mut ffi::GtkWidget,
2822 parentptr: *mut ffi::GtkWidget,
2823) {
2824 unsafe {
2825 let instance = &*(ptr as *mut T::Instance);
2826 let imp = instance.imp();
2827 let previous_parent: Borrowed<Option<Widget>> = from_glib_borrow(parentptr);
2828
2829 imp.parent_set(previous_parent.as_ref().as_ref());
2830 }
2831}
2832
2833unsafe extern "C" fn widget_hierarchy_changed<T: WidgetImpl>(
2834 ptr: *mut ffi::GtkWidget,
2835 toplevelptr: *mut ffi::GtkWidget,
2836) {
2837 unsafe {
2838 let instance = &*(ptr as *mut T::Instance);
2839 let imp = instance.imp();
2840 let previous_toplevel: Borrowed<Option<Widget>> = from_glib_borrow(toplevelptr);
2841
2842 imp.hierarchy_changed(previous_toplevel.as_ref().as_ref());
2843 }
2844}
2845
2846unsafe extern "C" fn widget_grab_notify<T: WidgetImpl>(
2847 ptr: *mut ffi::GtkWidget,
2848 was_grabbed: glib::ffi::gboolean,
2849) {
2850 unsafe {
2851 let instance = &*(ptr as *mut T::Instance);
2852 let imp = instance.imp();
2853 imp.grab_notify(from_glib(was_grabbed));
2854 }
2855}
2856
2857unsafe extern "C" fn widget_mnemonic_activate<T: WidgetImpl>(
2858 ptr: *mut ffi::GtkWidget,
2859 group_cycling: glib::ffi::gboolean,
2860) -> glib::ffi::gboolean {
2861 unsafe {
2862 let instance = &*(ptr as *mut T::Instance);
2863 let imp = instance.imp();
2864 imp.mnemonic_activate(from_glib(group_cycling)).into_glib()
2865 }
2866}
2867
2868unsafe extern "C" fn widget_move_focus<T: WidgetImpl>(
2869 ptr: *mut ffi::GtkWidget,
2870 direction: ffi::GtkDirectionType,
2871) {
2872 unsafe {
2873 let instance = &*(ptr as *mut T::Instance);
2874 let imp = instance.imp();
2875 imp.move_focus(from_glib(direction));
2876 }
2877}
2878
2879unsafe extern "C" fn widget_keynav_failed<T: WidgetImpl>(
2880 ptr: *mut ffi::GtkWidget,
2881 direction: ffi::GtkDirectionType,
2882) -> glib::ffi::gboolean {
2883 unsafe {
2884 let instance = &*(ptr as *mut T::Instance);
2885 let imp = instance.imp();
2886 imp.keynav_failed(from_glib(direction)).into_glib()
2887 }
2888}
2889
2890unsafe extern "C" fn widget_event<T: WidgetImpl>(
2891 ptr: *mut ffi::GtkWidget,
2892 evptr: *mut gdk::ffi::GdkEvent,
2893) -> glib::ffi::gboolean {
2894 unsafe {
2895 let instance = &*(ptr as *mut T::Instance);
2896 let imp = instance.imp();
2897 let event: Borrowed<gdk::Event> = from_glib_borrow(evptr);
2898
2899 imp.event(&event).into_glib()
2900 }
2901}
2902
2903unsafe extern "C" fn widget_property_notify_event<T: WidgetImpl>(
2904 ptr: *mut ffi::GtkWidget,
2905 evptr: *mut gdk::ffi::GdkEventProperty,
2906) -> glib::ffi::gboolean {
2907 unsafe {
2908 let instance = &*(ptr as *mut T::Instance);
2909 let imp = instance.imp();
2910 let event: Borrowed<gdk::EventProperty> = from_glib_borrow(evptr);
2911
2912 imp.property_notify_event(&event).into_glib()
2913 }
2914}
2915
2916unsafe extern "C" fn widget_selection_clear_event<T: WidgetImpl>(
2917 ptr: *mut ffi::GtkWidget,
2918 evptr: *mut gdk::ffi::GdkEventSelection,
2919) -> glib::ffi::gboolean {
2920 unsafe {
2921 let instance = &*(ptr as *mut T::Instance);
2922 let imp = instance.imp();
2923 let event: Borrowed<gdk::EventSelection> = from_glib_borrow(evptr);
2924
2925 imp.selection_clear_event(&event).into_glib()
2926 }
2927}
2928
2929unsafe extern "C" fn widget_selection_request_event<T: WidgetImpl>(
2930 ptr: *mut ffi::GtkWidget,
2931 evptr: *mut gdk::ffi::GdkEventSelection,
2932) -> glib::ffi::gboolean {
2933 unsafe {
2934 let instance = &*(ptr as *mut T::Instance);
2935 let imp = instance.imp();
2936 let event: Borrowed<gdk::EventSelection> = from_glib_borrow(evptr);
2937
2938 imp.selection_request_event(&event).into_glib()
2939 }
2940}
2941
2942unsafe extern "C" fn widget_selection_notify_event<T: WidgetImpl>(
2943 ptr: *mut ffi::GtkWidget,
2944 evptr: *mut gdk::ffi::GdkEventSelection,
2945) -> glib::ffi::gboolean {
2946 unsafe {
2947 let instance = &*(ptr as *mut T::Instance);
2948 let imp = instance.imp();
2949 let event: Borrowed<gdk::EventSelection> = from_glib_borrow(evptr);
2950
2951 imp.selection_notify_event(&event).into_glib()
2952 }
2953}
2954
2955unsafe extern "C" fn widget_proximity_in_event<T: WidgetImpl>(
2956 ptr: *mut ffi::GtkWidget,
2957 evptr: *mut gdk::ffi::GdkEventProximity,
2958) -> glib::ffi::gboolean {
2959 unsafe {
2960 let instance = &*(ptr as *mut T::Instance);
2961 let imp = instance.imp();
2962 let event: Borrowed<gdk::EventProximity> = from_glib_borrow(evptr);
2963
2964 imp.proximity_in_event(&event).into_glib()
2965 }
2966}
2967
2968unsafe extern "C" fn widget_proximity_out_event<T: WidgetImpl>(
2969 ptr: *mut ffi::GtkWidget,
2970 evptr: *mut gdk::ffi::GdkEventProximity,
2971) -> glib::ffi::gboolean {
2972 unsafe {
2973 let instance = &*(ptr as *mut T::Instance);
2974 let imp = instance.imp();
2975 let event: Borrowed<gdk::EventProximity> = from_glib_borrow(evptr);
2976
2977 imp.proximity_out_event(&event).into_glib()
2978 }
2979}
2980
2981unsafe extern "C" fn widget_visibility_notify_event<T: WidgetImpl>(
2982 ptr: *mut ffi::GtkWidget,
2983 evptr: *mut gdk::ffi::GdkEventVisibility,
2984) -> glib::ffi::gboolean {
2985 unsafe {
2986 let instance = &*(ptr as *mut T::Instance);
2987 let imp = instance.imp();
2988 let event: Borrowed<gdk::EventVisibility> = from_glib_borrow(evptr);
2989
2990 imp.visibility_notify_event(&event).into_glib()
2991 }
2992}
2993
2994unsafe extern "C" fn widget_grab_broken_event<T: WidgetImpl>(
2995 ptr: *mut ffi::GtkWidget,
2996 evptr: *mut gdk::ffi::GdkEventGrabBroken,
2997) -> glib::ffi::gboolean {
2998 unsafe {
2999 let instance = &*(ptr as *mut T::Instance);
3000 let imp = instance.imp();
3001 let event: Borrowed<gdk::EventGrabBroken> = from_glib_borrow(evptr);
3002
3003 imp.grab_broken_event(&event).into_glib()
3004 }
3005}
3006
3007unsafe extern "C" fn widget_touch_event<T: WidgetImpl>(
3008 ptr: *mut ffi::GtkWidget,
3009 evptr: *mut gdk::ffi::GdkEventTouch,
3010) -> glib::ffi::gboolean {
3011 unsafe {
3012 let instance = &*(ptr as *mut T::Instance);
3013 let imp = instance.imp();
3014 let event: Borrowed<gdk::EventTouch> = from_glib_borrow(evptr);
3015
3016 imp.touch_event(&event).into_glib()
3017 }
3018}
3019
3020unsafe extern "C" fn widget_selection_get<T: WidgetImpl>(
3021 ptr: *mut ffi::GtkWidget,
3022 selectptr: *mut ffi::GtkSelectionData,
3023 info: u32,
3024 time: u32,
3025) {
3026 unsafe {
3027 let instance = &*(ptr as *mut T::Instance);
3028 let imp = instance.imp();
3029 let selection_data: Borrowed<SelectionData> = from_glib_borrow(selectptr);
3030
3031 imp.selection_get(&selection_data, info, time);
3032 }
3033}
3034
3035unsafe extern "C" fn widget_selection_received<T: WidgetImpl>(
3036 ptr: *mut ffi::GtkWidget,
3037 selectptr: *mut ffi::GtkSelectionData,
3038 time: u32,
3039) {
3040 unsafe {
3041 let instance = &*(ptr as *mut T::Instance);
3042 let imp = instance.imp();
3043 let selection_data: Borrowed<SelectionData> = from_glib_borrow(selectptr);
3044
3045 imp.selection_received(&selection_data, time);
3046 }
3047}
3048
3049unsafe extern "C" fn widget_popup_menu<T: WidgetImpl>(
3050 ptr: *mut ffi::GtkWidget,
3051) -> glib::ffi::gboolean {
3052 unsafe {
3053 let instance = &*(ptr as *mut T::Instance);
3054 let imp = instance.imp();
3055 imp.popup_menu().into_glib()
3056 }
3057}
3058
3059unsafe extern "C" fn widget_show_help<T: WidgetImpl>(
3060 ptr: *mut ffi::GtkWidget,
3061 help_type: ffi::GtkWidgetHelpType,
3062) -> glib::ffi::gboolean {
3063 unsafe {
3064 let instance = &*(ptr as *mut T::Instance);
3065 let imp = instance.imp();
3066 imp.show_help(from_glib(help_type)).into_glib()
3067 }
3068}
3069
3070unsafe extern "C" fn widget_screen_changed<T: WidgetImpl>(
3071 ptr: *mut ffi::GtkWidget,
3072 screenptr: *mut gdk::ffi::GdkScreen,
3073) {
3074 unsafe {
3075 let instance = &*(ptr as *mut T::Instance);
3076 let imp = instance.imp();
3077 let previous_screen: Borrowed<Option<gdk::Screen>> = from_glib_borrow(screenptr);
3078
3079 imp.screen_changed(previous_screen.as_ref().as_ref());
3080 }
3081}
3082
3083unsafe extern "C" fn widget_query_tooltip<T: WidgetImpl>(
3084 ptr: *mut ffi::GtkWidget,
3085 x: c_int,
3086 y: c_int,
3087 keyboard_tooltip: glib::ffi::gboolean,
3088 tooltipptr: *mut ffi::GtkTooltip,
3089) -> glib::ffi::gboolean {
3090 unsafe {
3091 let instance = &*(ptr as *mut T::Instance);
3092 let imp = instance.imp();
3093 let tooltip: Borrowed<Tooltip> = from_glib_borrow(tooltipptr);
3094
3095 imp.query_tooltip(x, y, from_glib(keyboard_tooltip), &tooltip)
3096 .into_glib()
3097 }
3098}
3099
3100unsafe extern "C" fn widget_queue_draw_region<T: WidgetImpl>(
3101 ptr: *mut ffi::GtkWidget,
3102 regionptr: *const cairo::ffi::cairo_region_t,
3103) {
3104 unsafe {
3105 let instance = &*(ptr as *mut T::Instance);
3106 let imp = instance.imp();
3107 let region: Borrowed<cairo::Region> = from_glib_borrow(mut_override(regionptr));
3108
3109 imp.queue_draw_region(®ion);
3110 }
3111}
3112
3113pub unsafe trait WidgetClassSubclassExt: ClassStruct<Type: WidgetImpl> {
3114 fn set_accessible_type(&mut self, type_: glib::Type) {
3115 unsafe {
3116 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3117 ffi::gtk_widget_class_set_accessible_type(widget_class, type_.into_glib());
3118 }
3119 }
3120
3121 fn set_accessible_role(&mut self, role: atk::Role) {
3122 unsafe {
3123 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3124 ffi::gtk_widget_class_set_accessible_role(widget_class, role.into_glib());
3125 }
3126 }
3127
3128 fn set_template_bytes(&mut self, template: &glib::Bytes) {
3129 unsafe {
3130 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3131 ffi::gtk_widget_class_set_template(widget_class, template.to_glib_none().0);
3132 }
3133 }
3134
3135 fn enable_baseline_support(&mut self) {
3153 unsafe {
3154 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3155 (*widget_class).get_preferred_height_and_baseline_for_width =
3156 Some(widget_get_preferred_height_and_baseline_for_width::<Self::Type>);
3157 }
3158 }
3159
3160 fn set_template(&mut self, template: &[u8]) {
3161 let template_bytes = glib::Bytes::from(template);
3162 self.set_template_bytes(&template_bytes);
3163 }
3164
3165 fn set_template_static(&mut self, template: &'static [u8]) {
3166 let template_bytes = glib::Bytes::from_static(template);
3167 self.set_template_bytes(&template_bytes);
3168 }
3169
3170 fn set_template_from_resource(&mut self, resource_name: &str) {
3171 unsafe {
3172 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3173 ffi::gtk_widget_class_set_template_from_resource(
3174 widget_class,
3175 resource_name.to_glib_none().0,
3176 );
3177 }
3178 }
3179
3180 fn bind_template_child(&mut self, name: &str) {
3181 unsafe {
3182 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3183 ffi::gtk_widget_class_bind_template_child_full(
3184 widget_class,
3185 name.to_glib_none().0,
3186 false as glib::ffi::gboolean,
3187 0,
3188 );
3189 }
3190 }
3191
3192 #[allow(clippy::missing_safety_doc)]
3193 unsafe fn bind_template_child_with_offset<T>(
3194 &mut self,
3195 name: &str,
3196 offset: field_offset::FieldOffset<Self::Type, TemplateChild<T>>,
3197 ) where
3198 T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,
3199 {
3200 unsafe {
3201 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3202 let private_offset = <Self::Type as ObjectSubclassType>::type_data()
3203 .as_ref()
3204 .impl_offset();
3205 ffi::gtk_widget_class_bind_template_child_full(
3206 widget_class,
3207 name.to_glib_none().0,
3208 false as glib::ffi::gboolean,
3209 private_offset + (offset.get_byte_offset() as isize),
3210 )
3211 }
3212 }
3213
3214 #[doc(alias = "gtk_widget_class_set_css_name")]
3215 fn set_css_name(&mut self, name: &str) {
3216 unsafe {
3217 let widget_class = self as *mut _ as *mut ffi::GtkWidgetClass;
3218 ffi::gtk_widget_class_set_css_name(widget_class, name.to_glib_none().0);
3219 }
3220 }
3221
3222 #[doc(alias = "gtk_widget_class_get_css_name")]
3223 fn css_name(&self) -> glib::GString {
3224 unsafe {
3225 let widget_class = self as *const _ as *mut ffi::GtkWidgetClass;
3226 from_glib_none(ffi::gtk_widget_class_get_css_name(widget_class))
3227 }
3228 }
3229}
3230
3231unsafe impl<T: ClassStruct> WidgetClassSubclassExt for T where T::Type: WidgetImpl {}
3232
3233#[derive(Debug, PartialEq, Eq)]
3234#[repr(transparent)]
3235pub struct TemplateChild<T>
3236where
3237 T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,
3238{
3239 ptr: *mut <T as ObjectType>::GlibType,
3240}
3241
3242impl<T> Default for TemplateChild<T>
3243where
3244 T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,
3245{
3246 fn default() -> Self {
3247 Self {
3248 ptr: std::ptr::null_mut(),
3249 }
3250 }
3251}
3252
3253impl<T> std::ops::Deref for TemplateChild<T>
3254where
3255 T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,
3256{
3257 type Target = T;
3258
3259 fn deref(&self) -> &Self::Target {
3268 unsafe {
3269 assert!(!self.ptr.is_null());
3270 &*(&self.ptr as *const _ as *const T)
3271 }
3272 }
3273}
3274
3275impl<T> TemplateChild<T>
3276where
3277 T: ObjectType + FromGlibPtrNone<*mut <T as ObjectType>::GlibType>,
3278{
3279 #[track_caller]
3280 pub fn get(&self) -> T {
3281 unsafe {
3282 Option::<T>::from_glib_none(self.ptr)
3283 .expect("Failed to retrieve template child. Please check that it has been bound.")
3284 }
3285 }
3286}
3287
3288pub trait CompositeTemplate: WidgetImpl {
3289 fn bind_template(klass: &mut Self::Class);
3290}