1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use crate::TextBuffer; 6 use glib::object::IsA; 7 use glib::translate::*; 8 use std::mem; 9 use std::ptr; 10 11 glib::wrapper! { 12 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 13 pub struct SelectionData(Boxed<ffi::GtkSelectionData>); 14 15 match fn { 16 copy => |ptr| ffi::gtk_selection_data_copy(ptr), 17 free => |ptr| ffi::gtk_selection_data_free(ptr), 18 type_ => || ffi::gtk_selection_data_get_type(), 19 } 20 } 21 22 impl SelectionData { 23 #[doc(alias = "gtk_selection_data_get_data_type")] 24 #[doc(alias = "get_data_type")] data_type(&self) -> gdk::Atom25 pub fn data_type(&self) -> gdk::Atom { 26 unsafe { from_glib_none(ffi::gtk_selection_data_get_data_type(self.to_glib_none().0)) } 27 } 28 29 #[doc(alias = "gtk_selection_data_get_display")] 30 #[doc(alias = "get_display")] display(&self) -> Option<gdk::Display>31 pub fn display(&self) -> Option<gdk::Display> { 32 unsafe { from_glib_none(ffi::gtk_selection_data_get_display(self.to_glib_none().0)) } 33 } 34 35 #[doc(alias = "gtk_selection_data_get_format")] 36 #[doc(alias = "get_format")] format(&self) -> i3237 pub fn format(&self) -> i32 { 38 unsafe { ffi::gtk_selection_data_get_format(self.to_glib_none().0) } 39 } 40 41 #[doc(alias = "gtk_selection_data_get_length")] 42 #[doc(alias = "get_length")] length(&self) -> i3243 pub fn length(&self) -> i32 { 44 unsafe { ffi::gtk_selection_data_get_length(self.to_glib_none().0) } 45 } 46 47 #[doc(alias = "gtk_selection_data_get_pixbuf")] 48 #[doc(alias = "get_pixbuf")] pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>49 pub fn pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> { 50 unsafe { from_glib_full(ffi::gtk_selection_data_get_pixbuf(self.to_glib_none().0)) } 51 } 52 53 #[doc(alias = "gtk_selection_data_get_selection")] 54 #[doc(alias = "get_selection")] selection(&self) -> gdk::Atom55 pub fn selection(&self) -> gdk::Atom { 56 unsafe { from_glib_none(ffi::gtk_selection_data_get_selection(self.to_glib_none().0)) } 57 } 58 59 #[doc(alias = "gtk_selection_data_get_target")] 60 #[doc(alias = "get_target")] target(&self) -> gdk::Atom61 pub fn target(&self) -> gdk::Atom { 62 unsafe { from_glib_none(ffi::gtk_selection_data_get_target(self.to_glib_none().0)) } 63 } 64 65 #[doc(alias = "gtk_selection_data_get_targets")] 66 #[doc(alias = "get_targets")] targets(&self) -> Option<Vec<gdk::Atom>>67 pub fn targets(&self) -> Option<Vec<gdk::Atom>> { 68 unsafe { 69 let mut targets = ptr::null_mut(); 70 let mut n_atoms = mem::MaybeUninit::uninit(); 71 let ret = from_glib(ffi::gtk_selection_data_get_targets( 72 self.to_glib_none().0, 73 &mut targets, 74 n_atoms.as_mut_ptr(), 75 )); 76 if ret { 77 Some(FromGlibContainer::from_glib_container_num( 78 targets, 79 n_atoms.assume_init() as usize, 80 )) 81 } else { 82 None 83 } 84 } 85 } 86 87 #[doc(alias = "gtk_selection_data_get_text")] 88 #[doc(alias = "get_text")] text(&self) -> Option<glib::GString>89 pub fn text(&self) -> Option<glib::GString> { 90 unsafe { from_glib_full(ffi::gtk_selection_data_get_text(self.to_glib_none().0)) } 91 } 92 93 #[doc(alias = "gtk_selection_data_get_uris")] 94 #[doc(alias = "get_uris")] uris(&self) -> Vec<glib::GString>95 pub fn uris(&self) -> Vec<glib::GString> { 96 unsafe { 97 FromGlibPtrContainer::from_glib_full(ffi::gtk_selection_data_get_uris( 98 self.to_glib_none().0, 99 )) 100 } 101 } 102 103 #[doc(alias = "gtk_selection_data_set")] set(&self, type_: &gdk::Atom, format: i32, data: &[u8])104 pub fn set(&self, type_: &gdk::Atom, format: i32, data: &[u8]) { 105 let length = data.len() as i32; 106 unsafe { 107 ffi::gtk_selection_data_set( 108 mut_override(self.to_glib_none().0), 109 type_.to_glib_none().0, 110 format, 111 data.to_glib_none().0, 112 length, 113 ); 114 } 115 } 116 117 #[doc(alias = "gtk_selection_data_set_pixbuf")] set_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) -> bool118 pub fn set_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) -> bool { 119 unsafe { 120 from_glib(ffi::gtk_selection_data_set_pixbuf( 121 mut_override(self.to_glib_none().0), 122 pixbuf.to_glib_none().0, 123 )) 124 } 125 } 126 127 #[doc(alias = "gtk_selection_data_set_text")] set_text(&self, str: &str) -> bool128 pub fn set_text(&self, str: &str) -> bool { 129 let len = str.len() as i32; 130 unsafe { 131 from_glib(ffi::gtk_selection_data_set_text( 132 mut_override(self.to_glib_none().0), 133 str.to_glib_none().0, 134 len, 135 )) 136 } 137 } 138 139 #[doc(alias = "gtk_selection_data_set_uris")] set_uris(&self, uris: &[&str]) -> bool140 pub fn set_uris(&self, uris: &[&str]) -> bool { 141 unsafe { 142 from_glib(ffi::gtk_selection_data_set_uris( 143 mut_override(self.to_glib_none().0), 144 uris.to_glib_none().0, 145 )) 146 } 147 } 148 149 #[doc(alias = "gtk_selection_data_targets_include_image")] targets_include_image(&self, writable: bool) -> bool150 pub fn targets_include_image(&self, writable: bool) -> bool { 151 unsafe { 152 from_glib(ffi::gtk_selection_data_targets_include_image( 153 self.to_glib_none().0, 154 writable.into_glib(), 155 )) 156 } 157 } 158 159 #[doc(alias = "gtk_selection_data_targets_include_rich_text")] targets_include_rich_text<P: IsA<TextBuffer>>(&self, buffer: &P) -> bool160 pub fn targets_include_rich_text<P: IsA<TextBuffer>>(&self, buffer: &P) -> bool { 161 unsafe { 162 from_glib(ffi::gtk_selection_data_targets_include_rich_text( 163 self.to_glib_none().0, 164 buffer.as_ref().to_glib_none().0, 165 )) 166 } 167 } 168 169 #[doc(alias = "gtk_selection_data_targets_include_text")] targets_include_text(&self) -> bool170 pub fn targets_include_text(&self) -> bool { 171 unsafe { 172 from_glib(ffi::gtk_selection_data_targets_include_text( 173 self.to_glib_none().0, 174 )) 175 } 176 } 177 178 #[doc(alias = "gtk_selection_data_targets_include_uri")] targets_include_uri(&self) -> bool179 pub fn targets_include_uri(&self) -> bool { 180 unsafe { 181 from_glib(ffi::gtk_selection_data_targets_include_uri( 182 self.to_glib_none().0, 183 )) 184 } 185 } 186 } 187