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 gdk; 6 use gdk_pixbuf; 7 use glib::object::IsA; 8 use glib::translate::*; 9 use glib::GString; 10 use gtk_sys; 11 use std::mem; 12 use std::ptr; 13 use TextBuffer; 14 15 glib_wrapper! { 16 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 17 pub struct SelectionData(Boxed<gtk_sys::GtkSelectionData>); 18 19 match fn { 20 copy => |ptr| gtk_sys::gtk_selection_data_copy(mut_override(ptr)), 21 free => |ptr| gtk_sys::gtk_selection_data_free(ptr), 22 get_type => || gtk_sys::gtk_selection_data_get_type(), 23 } 24 } 25 26 impl SelectionData { get_data_type(&self) -> gdk::Atom27 pub fn get_data_type(&self) -> gdk::Atom { 28 unsafe { 29 from_glib_none(gtk_sys::gtk_selection_data_get_data_type( 30 self.to_glib_none().0, 31 )) 32 } 33 } 34 get_display(&self) -> Option<gdk::Display>35 pub fn get_display(&self) -> Option<gdk::Display> { 36 unsafe { 37 from_glib_none(gtk_sys::gtk_selection_data_get_display( 38 self.to_glib_none().0, 39 )) 40 } 41 } 42 get_format(&self) -> i3243 pub fn get_format(&self) -> i32 { 44 unsafe { gtk_sys::gtk_selection_data_get_format(self.to_glib_none().0) } 45 } 46 get_length(&self) -> i3247 pub fn get_length(&self) -> i32 { 48 unsafe { gtk_sys::gtk_selection_data_get_length(self.to_glib_none().0) } 49 } 50 get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>51 pub fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> { 52 unsafe { 53 from_glib_full(gtk_sys::gtk_selection_data_get_pixbuf( 54 self.to_glib_none().0, 55 )) 56 } 57 } 58 get_selection(&self) -> gdk::Atom59 pub fn get_selection(&self) -> gdk::Atom { 60 unsafe { 61 from_glib_none(gtk_sys::gtk_selection_data_get_selection( 62 self.to_glib_none().0, 63 )) 64 } 65 } 66 get_target(&self) -> gdk::Atom67 pub fn get_target(&self) -> gdk::Atom { 68 unsafe { 69 from_glib_none(gtk_sys::gtk_selection_data_get_target( 70 self.to_glib_none().0, 71 )) 72 } 73 } 74 get_targets(&self) -> Option<Vec<gdk::Atom>>75 pub fn get_targets(&self) -> Option<Vec<gdk::Atom>> { 76 unsafe { 77 let mut targets = ptr::null_mut(); 78 let mut n_atoms = mem::MaybeUninit::uninit(); 79 let ret = from_glib(gtk_sys::gtk_selection_data_get_targets( 80 self.to_glib_none().0, 81 &mut targets, 82 n_atoms.as_mut_ptr(), 83 )); 84 if ret { 85 Some(FromGlibContainer::from_glib_container_num( 86 targets, 87 n_atoms.assume_init() as usize, 88 )) 89 } else { 90 None 91 } 92 } 93 } 94 get_text(&self) -> Option<GString>95 pub fn get_text(&self) -> Option<GString> { 96 unsafe { from_glib_full(gtk_sys::gtk_selection_data_get_text(self.to_glib_none().0)) } 97 } 98 get_uris(&self) -> Vec<GString>99 pub fn get_uris(&self) -> Vec<GString> { 100 unsafe { 101 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_selection_data_get_uris( 102 self.to_glib_none().0, 103 )) 104 } 105 } 106 set(&self, type_: &gdk::Atom, format: i32, data: &[u8])107 pub fn set(&self, type_: &gdk::Atom, format: i32, data: &[u8]) { 108 let length = data.len() as i32; 109 unsafe { 110 gtk_sys::gtk_selection_data_set( 111 mut_override(self.to_glib_none().0), 112 type_.to_glib_none().0, 113 format, 114 data.to_glib_none().0, 115 length, 116 ); 117 } 118 } 119 set_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) -> bool120 pub fn set_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) -> bool { 121 unsafe { 122 from_glib(gtk_sys::gtk_selection_data_set_pixbuf( 123 mut_override(self.to_glib_none().0), 124 pixbuf.to_glib_none().0, 125 )) 126 } 127 } 128 set_text(&self, str: &str) -> bool129 pub fn set_text(&self, str: &str) -> bool { 130 let len = str.len() as i32; 131 unsafe { 132 from_glib(gtk_sys::gtk_selection_data_set_text( 133 mut_override(self.to_glib_none().0), 134 str.to_glib_none().0, 135 len, 136 )) 137 } 138 } 139 set_uris(&self, uris: &[&str]) -> bool140 pub fn set_uris(&self, uris: &[&str]) -> bool { 141 unsafe { 142 from_glib(gtk_sys::gtk_selection_data_set_uris( 143 mut_override(self.to_glib_none().0), 144 uris.to_glib_none().0, 145 )) 146 } 147 } 148 targets_include_image(&self, writable: bool) -> bool149 pub fn targets_include_image(&self, writable: bool) -> bool { 150 unsafe { 151 from_glib(gtk_sys::gtk_selection_data_targets_include_image( 152 self.to_glib_none().0, 153 writable.to_glib(), 154 )) 155 } 156 } 157 targets_include_rich_text<P: IsA<TextBuffer>>(&self, buffer: &P) -> bool158 pub fn targets_include_rich_text<P: IsA<TextBuffer>>(&self, buffer: &P) -> bool { 159 unsafe { 160 from_glib(gtk_sys::gtk_selection_data_targets_include_rich_text( 161 self.to_glib_none().0, 162 buffer.as_ref().to_glib_none().0, 163 )) 164 } 165 } 166 targets_include_text(&self) -> bool167 pub fn targets_include_text(&self) -> bool { 168 unsafe { 169 from_glib(gtk_sys::gtk_selection_data_targets_include_text( 170 self.to_glib_none().0, 171 )) 172 } 173 } 174 targets_include_uri(&self) -> bool175 pub fn targets_include_uri(&self) -> bool { 176 unsafe { 177 from_glib(gtk_sys::gtk_selection_data_targets_include_uri( 178 self.to_glib_none().0, 179 )) 180 } 181 } 182 } 183