|
| 1 | +// This file was generated by gir (https://github.com/gtk-rs/gir @ e895709+) |
| 2 | +// from gir-files (https://github.com/gtk-rs/gir-files @ 47c69e6) |
| 3 | +// DO NOT EDIT |
| 4 | + |
| 5 | +#[allow(unused_imports)] |
| 6 | +use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double, |
| 7 | + c_short, c_ushort, c_long, c_ulong, |
| 8 | + c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE}; |
| 9 | + |
| 10 | +#[allow(unused_imports)] |
| 11 | +use glib_ffi::{gboolean, gconstpointer, gpointer, GType}; |
| 12 | + |
| 13 | +use gio; |
| 14 | +use gio_ffi; |
| 15 | +use glib; |
| 16 | +use glib::object::IsA; |
| 17 | +use glib::translate::*; |
| 18 | +use glib_ffi; |
| 19 | +use gobject_ffi; |
| 20 | +use std::mem; |
| 21 | +use std::ptr; |
| 22 | + |
| 23 | +use gobject_subclass::anyimpl::*; |
| 24 | +use gobject_subclass::object::*; |
| 25 | + |
| 26 | + |
| 27 | +pub trait ActionMapImpl: AnyImpl + 'static { |
| 28 | + |
| 29 | + fn add_action(&self, action_map: &gio::ActionMap, action: &gio::Action); |
| 30 | + |
| 31 | + fn lookup_action(&self, action_map: &gio::ActionMap, action_name: &str) -> Option<gio::Action>; |
| 32 | + |
| 33 | + fn remove_action(&self, action_map: &gio::ActionMap, action_name: &str); |
| 34 | + |
| 35 | +} |
| 36 | + |
| 37 | +any_impl!(ActionMapImpl); |
| 38 | + |
| 39 | +pub trait ActionMapImplStatic<T: ObjectType>: 'static { |
| 40 | + fn get_impl<'a>(&self, imp: &'a T::ImplType) -> &'a ActionMapImpl; |
| 41 | +} |
| 42 | + |
| 43 | +struct ActionMapStatic<T: ObjectType>{ |
| 44 | + imp_static: *const ActionMapImplStatic<T> |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +unsafe extern "C" fn action_map_add_action<T: ObjectType> |
| 49 | +(gptr: *mut gio_ffi::GActionMap, action: *mut gio_ffi::GAction) |
| 50 | +{ |
| 51 | + floating_reference_guard!(gptr); |
| 52 | + let klass = &**(gptr as *const *const ClassStruct<T>); |
| 53 | + let interface_static = klass.get_interface_static(gio_ffi::g_action_map_get_type()) |
| 54 | + as *const ActionMapStatic<T>; |
| 55 | + let instance = &*(gptr as *const T::InstanceStructType); |
| 56 | + let imp = instance.get_impl(); |
| 57 | + let imp = (*(*interface_static).imp_static).get_impl(imp); |
| 58 | + let wrap = from_glib_borrow(gptr); |
| 59 | + imp.add_action(&wrap, &from_glib_none(action)); |
| 60 | +} |
| 61 | + |
| 62 | +unsafe extern "C" fn action_map_lookup_action<T: ObjectType> |
| 63 | +(gptr: *mut gio_ffi::GActionMap, action_name: *const c_char) -> *mut gio_ffi::GAction |
| 64 | +{ |
| 65 | + floating_reference_guard!(gptr); |
| 66 | + let klass = &**(gptr as *const *const ClassStruct<T>); |
| 67 | + let interface_static = klass.get_interface_static(gio_ffi::g_action_map_get_type()) |
| 68 | + as *const ActionMapStatic<T>; |
| 69 | + let instance = &*(gptr as *const T::InstanceStructType); |
| 70 | + let imp = instance.get_impl(); |
| 71 | + let imp = (*(*interface_static).imp_static).get_impl(imp); |
| 72 | + let wrap = from_glib_borrow(gptr); |
| 73 | + let rs_ret = imp.lookup_action(&wrap, &String::from_glib_none(action_name)); |
| 74 | + |
| 75 | + match rs_ret { |
| 76 | + Some(t_ret) => { |
| 77 | + let ret = t_ret.to_glib_full(); |
| 78 | + unsafe extern "C" fn destroy_ret(p: glib_ffi::gpointer){ |
| 79 | + let _: gio::Action = gio::Action::from_glib_full(p as *mut gio_ffi::GAction); |
| 80 | + }; |
| 81 | + gobject_ffi::g_object_set_qdata_full(gptr as *mut gobject_ffi::GObject, |
| 82 | + glib_ffi::g_quark_from_string("rs_action_map_lookup_action_ret".to_glib_none().0), |
| 83 | + ret as *mut c_void, |
| 84 | + Some(destroy_ret) |
| 85 | + ); |
| 86 | + ret |
| 87 | + }, |
| 88 | + None => ptr::null_mut() |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +unsafe extern "C" fn action_map_remove_action<T: ObjectType> |
| 93 | +(gptr: *mut gio_ffi::GActionMap, action_name: *const c_char) |
| 94 | +{ |
| 95 | + floating_reference_guard!(gptr); |
| 96 | + let klass = &**(gptr as *const *const ClassStruct<T>); |
| 97 | + let interface_static = klass.get_interface_static(gio_ffi::g_action_map_get_type()) |
| 98 | + as *const ActionMapStatic<T>; |
| 99 | + let instance = &*(gptr as *const T::InstanceStructType); |
| 100 | + let imp = instance.get_impl(); |
| 101 | + let imp = (*(*interface_static).imp_static).get_impl(imp); |
| 102 | + let wrap = from_glib_borrow(gptr); |
| 103 | + imp.remove_action(&wrap, &String::from_glib_none(action_name)); |
| 104 | +} |
| 105 | + |
| 106 | +unsafe extern "C" fn action_map_init<T: ObjectType>( |
| 107 | + iface: glib_ffi::gpointer, |
| 108 | + iface_data: glib_ffi::gpointer |
| 109 | +) { |
| 110 | + let action_map_iface = &mut *(iface as *mut gio_ffi::GActionMapInterface); |
| 111 | + let iface_type = (*(iface as *const gobject_ffi::GTypeInterface)).g_type; |
| 112 | + let type_ = (*(iface as *const gobject_ffi::GTypeInterface)).g_instance_type; |
| 113 | + let klass = &mut *(gobject_ffi::g_type_class_ref(type_) as *mut ClassStruct<T>); |
| 114 | + let interfaces_static = &mut *(klass.interfaces_static as *mut Vec<_>); |
| 115 | + interfaces_static.push((iface_type, iface_data)); |
| 116 | + action_map_iface.add_action = Some(action_map_add_action::<T>); |
| 117 | + action_map_iface.lookup_action = Some(action_map_lookup_action::<T>); |
| 118 | + action_map_iface.remove_action = Some(action_map_remove_action::<T>); |
| 119 | +} |
| 120 | + |
| 121 | +pub fn register_action_map<T: ObjectType, I: ActionMapImplStatic<T>>( |
| 122 | + _: &TypeInitToken, |
| 123 | + type_: glib::Type, |
| 124 | + imp: &I, |
| 125 | +) { |
| 126 | + |
| 127 | + unsafe { |
| 128 | + let imp = imp as &ActionMapImplStatic<T> as *const ActionMapImplStatic<T>; |
| 129 | + let interface_static = Box::new(ActionMapStatic { |
| 130 | + imp_static: imp, |
| 131 | + }); |
| 132 | + let iface_info = gobject_ffi::GInterfaceInfo { |
| 133 | + interface_init: Some(action_map_init::<T>), |
| 134 | + interface_finalize: None, |
| 135 | + interface_data: Box::into_raw(interface_static) as glib_ffi::gpointer, |
| 136 | + }; |
| 137 | + gobject_ffi::g_type_add_interface_static( |
| 138 | + type_.to_glib(), |
| 139 | + gio_ffi::g_action_map_get_type(), |
| 140 | + &iface_info, |
| 141 | + ); |
| 142 | + } |
| 143 | + |
| 144 | +} |
0 commit comments