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