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::Clipboard; 6 use crate::TargetList; 7 use crate::TextChildAnchor; 8 use crate::TextIter; 9 use crate::TextMark; 10 use crate::TextTag; 11 use crate::TextTagTable; 12 use glib::object::Cast; 13 use glib::object::IsA; 14 use glib::signal::connect_raw; 15 use glib::signal::SignalHandlerId; 16 use glib::translate::*; 17 use glib::StaticType; 18 use glib::ToValue; 19 use std::boxed::Box as Box_; 20 use std::fmt; 21 use std::mem; 22 use std::mem::transmute; 23 use std::ptr; 24 25 glib::wrapper! { 26 #[doc(alias = "GtkTextBuffer")] 27 pub struct TextBuffer(Object<ffi::GtkTextBuffer, ffi::GtkTextBufferClass>); 28 29 match fn { 30 type_ => || ffi::gtk_text_buffer_get_type(), 31 } 32 } 33 34 impl TextBuffer { 35 #[doc(alias = "gtk_text_buffer_new")] new<P: IsA<TextTagTable>>(table: Option<&P>) -> TextBuffer36 pub fn new<P: IsA<TextTagTable>>(table: Option<&P>) -> TextBuffer { 37 assert_initialized_main_thread!(); 38 unsafe { 39 from_glib_full(ffi::gtk_text_buffer_new( 40 table.map(|p| p.as_ref()).to_glib_none().0, 41 )) 42 } 43 } 44 45 // rustdoc-stripper-ignore-next 46 /// Creates a new builder-pattern struct instance to construct [`TextBuffer`] objects. 47 /// 48 /// This method returns an instance of [`TextBufferBuilder`] which can be used to create [`TextBuffer`] objects. builder() -> TextBufferBuilder49 pub fn builder() -> TextBufferBuilder { 50 TextBufferBuilder::default() 51 } 52 } 53 54 #[derive(Clone, Default)] 55 // rustdoc-stripper-ignore-next 56 /// A [builder-pattern] type to construct [`TextBuffer`] objects. 57 /// 58 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 59 pub struct TextBufferBuilder { 60 tag_table: Option<TextTagTable>, 61 text: Option<String>, 62 } 63 64 impl TextBufferBuilder { 65 // rustdoc-stripper-ignore-next 66 /// Create a new [`TextBufferBuilder`]. new() -> Self67 pub fn new() -> Self { 68 Self::default() 69 } 70 71 // rustdoc-stripper-ignore-next 72 /// Build the [`TextBuffer`]. build(self) -> TextBuffer73 pub fn build(self) -> TextBuffer { 74 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 75 if let Some(ref tag_table) = self.tag_table { 76 properties.push(("tag-table", tag_table)); 77 } 78 if let Some(ref text) = self.text { 79 properties.push(("text", text)); 80 } 81 glib::Object::new::<TextBuffer>(&properties) 82 .expect("Failed to create an instance of TextBuffer") 83 } 84 tag_table<P: IsA<TextTagTable>>(mut self, tag_table: &P) -> Self85 pub fn tag_table<P: IsA<TextTagTable>>(mut self, tag_table: &P) -> Self { 86 self.tag_table = Some(tag_table.clone().upcast()); 87 self 88 } 89 text(mut self, text: &str) -> Self90 pub fn text(mut self, text: &str) -> Self { 91 self.text = Some(text.to_string()); 92 self 93 } 94 } 95 96 pub const NONE_TEXT_BUFFER: Option<&TextBuffer> = None; 97 98 pub trait TextBufferExt: 'static { 99 #[doc(alias = "gtk_text_buffer_add_mark")] add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter)100 fn add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter); 101 102 #[doc(alias = "gtk_text_buffer_add_selection_clipboard")] add_selection_clipboard(&self, clipboard: &Clipboard)103 fn add_selection_clipboard(&self, clipboard: &Clipboard); 104 105 #[doc(alias = "gtk_text_buffer_apply_tag")] apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter)106 fn apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter); 107 108 #[doc(alias = "gtk_text_buffer_apply_tag_by_name")] apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)109 fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter); 110 111 #[doc(alias = "gtk_text_buffer_backspace")] backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool112 fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool; 113 114 #[doc(alias = "gtk_text_buffer_begin_user_action")] begin_user_action(&self)115 fn begin_user_action(&self); 116 117 #[doc(alias = "gtk_text_buffer_copy_clipboard")] copy_clipboard(&self, clipboard: &Clipboard)118 fn copy_clipboard(&self, clipboard: &Clipboard); 119 120 #[doc(alias = "gtk_text_buffer_create_child_anchor")] create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor>121 fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor>; 122 123 #[doc(alias = "gtk_text_buffer_create_mark")] create_mark( &self, mark_name: Option<&str>, where_: &TextIter, left_gravity: bool, ) -> Option<TextMark>124 fn create_mark( 125 &self, 126 mark_name: Option<&str>, 127 where_: &TextIter, 128 left_gravity: bool, 129 ) -> Option<TextMark>; 130 131 //#[doc(alias = "gtk_text_buffer_create_tag")] 132 //fn create_tag(&self, tag_name: Option<&str>, first_property_name: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag>; 133 134 #[doc(alias = "gtk_text_buffer_cut_clipboard")] cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool)135 fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool); 136 137 #[doc(alias = "gtk_text_buffer_delete")] delete(&self, start: &mut TextIter, end: &mut TextIter)138 fn delete(&self, start: &mut TextIter, end: &mut TextIter); 139 140 #[doc(alias = "gtk_text_buffer_delete_interactive")] delete_interactive( &self, start_iter: &mut TextIter, end_iter: &mut TextIter, default_editable: bool, ) -> bool141 fn delete_interactive( 142 &self, 143 start_iter: &mut TextIter, 144 end_iter: &mut TextIter, 145 default_editable: bool, 146 ) -> bool; 147 148 #[doc(alias = "gtk_text_buffer_delete_mark")] delete_mark<P: IsA<TextMark>>(&self, mark: &P)149 fn delete_mark<P: IsA<TextMark>>(&self, mark: &P); 150 151 #[doc(alias = "gtk_text_buffer_delete_mark_by_name")] delete_mark_by_name(&self, name: &str)152 fn delete_mark_by_name(&self, name: &str); 153 154 #[doc(alias = "gtk_text_buffer_delete_selection")] delete_selection(&self, interactive: bool, default_editable: bool) -> bool155 fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool; 156 157 #[doc(alias = "gtk_text_buffer_deserialize")] deserialize<P: IsA<TextBuffer>>( &self, content_buffer: &P, format: &gdk::Atom, iter: &mut TextIter, data: &[u8], ) -> Result<(), glib::Error>158 fn deserialize<P: IsA<TextBuffer>>( 159 &self, 160 content_buffer: &P, 161 format: &gdk::Atom, 162 iter: &mut TextIter, 163 data: &[u8], 164 ) -> Result<(), glib::Error>; 165 166 #[doc(alias = "gtk_text_buffer_deserialize_get_can_create_tags")] deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool167 fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool; 168 169 #[doc(alias = "gtk_text_buffer_deserialize_set_can_create_tags")] deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool)170 fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool); 171 172 #[doc(alias = "gtk_text_buffer_end_user_action")] end_user_action(&self)173 fn end_user_action(&self); 174 175 #[doc(alias = "gtk_text_buffer_get_bounds")] 176 #[doc(alias = "get_bounds")] bounds(&self) -> (TextIter, TextIter)177 fn bounds(&self) -> (TextIter, TextIter); 178 179 #[doc(alias = "gtk_text_buffer_get_char_count")] 180 #[doc(alias = "get_char_count")] char_count(&self) -> i32181 fn char_count(&self) -> i32; 182 183 #[doc(alias = "gtk_text_buffer_get_copy_target_list")] 184 #[doc(alias = "get_copy_target_list")] copy_target_list(&self) -> Option<TargetList>185 fn copy_target_list(&self) -> Option<TargetList>; 186 187 #[doc(alias = "gtk_text_buffer_get_deserialize_formats")] 188 #[doc(alias = "get_deserialize_formats")] deserialize_formats(&self) -> Vec<gdk::Atom>189 fn deserialize_formats(&self) -> Vec<gdk::Atom>; 190 191 #[doc(alias = "gtk_text_buffer_get_end_iter")] 192 #[doc(alias = "get_end_iter")] end_iter(&self) -> TextIter193 fn end_iter(&self) -> TextIter; 194 195 #[doc(alias = "gtk_text_buffer_get_has_selection")] 196 #[doc(alias = "get_has_selection")] has_selection(&self) -> bool197 fn has_selection(&self) -> bool; 198 199 #[doc(alias = "gtk_text_buffer_get_insert")] get_insert(&self) -> Option<TextMark>200 fn get_insert(&self) -> Option<TextMark>; 201 202 #[doc(alias = "gtk_text_buffer_get_iter_at_child_anchor")] 203 #[doc(alias = "get_iter_at_child_anchor")] iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter204 fn iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter; 205 206 #[doc(alias = "gtk_text_buffer_get_iter_at_line")] 207 #[doc(alias = "get_iter_at_line")] iter_at_line(&self, line_number: i32) -> TextIter208 fn iter_at_line(&self, line_number: i32) -> TextIter; 209 210 #[doc(alias = "gtk_text_buffer_get_iter_at_line_index")] 211 #[doc(alias = "get_iter_at_line_index")] iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter212 fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter; 213 214 #[doc(alias = "gtk_text_buffer_get_iter_at_line_offset")] 215 #[doc(alias = "get_iter_at_line_offset")] iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter216 fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter; 217 218 #[doc(alias = "gtk_text_buffer_get_iter_at_mark")] 219 #[doc(alias = "get_iter_at_mark")] iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter220 fn iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter; 221 222 #[doc(alias = "gtk_text_buffer_get_iter_at_offset")] 223 #[doc(alias = "get_iter_at_offset")] iter_at_offset(&self, char_offset: i32) -> TextIter224 fn iter_at_offset(&self, char_offset: i32) -> TextIter; 225 226 #[doc(alias = "gtk_text_buffer_get_line_count")] 227 #[doc(alias = "get_line_count")] line_count(&self) -> i32228 fn line_count(&self) -> i32; 229 230 #[doc(alias = "gtk_text_buffer_get_mark")] 231 #[doc(alias = "get_mark")] mark(&self, name: &str) -> Option<TextMark>232 fn mark(&self, name: &str) -> Option<TextMark>; 233 234 #[doc(alias = "gtk_text_buffer_get_modified")] 235 #[doc(alias = "get_modified")] is_modified(&self) -> bool236 fn is_modified(&self) -> bool; 237 238 #[doc(alias = "gtk_text_buffer_get_paste_target_list")] 239 #[doc(alias = "get_paste_target_list")] paste_target_list(&self) -> Option<TargetList>240 fn paste_target_list(&self) -> Option<TargetList>; 241 242 #[doc(alias = "gtk_text_buffer_get_selection_bound")] 243 #[doc(alias = "get_selection_bound")] selection_bound(&self) -> Option<TextMark>244 fn selection_bound(&self) -> Option<TextMark>; 245 246 #[doc(alias = "gtk_text_buffer_get_selection_bounds")] 247 #[doc(alias = "get_selection_bounds")] selection_bounds(&self) -> Option<(TextIter, TextIter)>248 fn selection_bounds(&self) -> Option<(TextIter, TextIter)>; 249 250 #[doc(alias = "gtk_text_buffer_get_serialize_formats")] 251 #[doc(alias = "get_serialize_formats")] serialize_formats(&self) -> Vec<gdk::Atom>252 fn serialize_formats(&self) -> Vec<gdk::Atom>; 253 254 #[doc(alias = "gtk_text_buffer_get_slice")] 255 #[doc(alias = "get_slice")] slice( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> Option<glib::GString>256 fn slice( 257 &self, 258 start: &TextIter, 259 end: &TextIter, 260 include_hidden_chars: bool, 261 ) -> Option<glib::GString>; 262 263 #[doc(alias = "gtk_text_buffer_get_start_iter")] 264 #[doc(alias = "get_start_iter")] start_iter(&self) -> TextIter265 fn start_iter(&self) -> TextIter; 266 267 #[doc(alias = "gtk_text_buffer_get_tag_table")] 268 #[doc(alias = "get_tag_table")] tag_table(&self) -> Option<TextTagTable>269 fn tag_table(&self) -> Option<TextTagTable>; 270 271 #[doc(alias = "gtk_text_buffer_get_text")] 272 #[doc(alias = "get_text")] text( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> Option<glib::GString>273 fn text( 274 &self, 275 start: &TextIter, 276 end: &TextIter, 277 include_hidden_chars: bool, 278 ) -> Option<glib::GString>; 279 280 #[doc(alias = "gtk_text_buffer_insert")] insert(&self, iter: &mut TextIter, text: &str)281 fn insert(&self, iter: &mut TextIter, text: &str); 282 283 #[doc(alias = "gtk_text_buffer_insert_at_cursor")] insert_at_cursor(&self, text: &str)284 fn insert_at_cursor(&self, text: &str); 285 286 #[doc(alias = "gtk_text_buffer_insert_child_anchor")] insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P)287 fn insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P); 288 289 #[doc(alias = "gtk_text_buffer_insert_interactive")] insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool290 fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool; 291 292 #[doc(alias = "gtk_text_buffer_insert_interactive_at_cursor")] insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool293 fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool; 294 295 #[doc(alias = "gtk_text_buffer_insert_markup")] insert_markup(&self, iter: &mut TextIter, markup: &str)296 fn insert_markup(&self, iter: &mut TextIter, markup: &str); 297 298 #[doc(alias = "gtk_text_buffer_insert_pixbuf")] insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf)299 fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf); 300 301 #[doc(alias = "gtk_text_buffer_insert_range")] insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter)302 fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter); 303 304 #[doc(alias = "gtk_text_buffer_insert_range_interactive")] insert_range_interactive( &self, iter: &mut TextIter, start: &TextIter, end: &TextIter, default_editable: bool, ) -> bool305 fn insert_range_interactive( 306 &self, 307 iter: &mut TextIter, 308 start: &TextIter, 309 end: &TextIter, 310 default_editable: bool, 311 ) -> bool; 312 313 //#[doc(alias = "gtk_text_buffer_insert_with_tags")] 314 //fn insert_with_tags<P: IsA<TextTag>>(&self, iter: &mut TextIter, text: &str, first_tag: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); 315 316 //#[doc(alias = "gtk_text_buffer_insert_with_tags_by_name")] 317 //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); 318 319 #[doc(alias = "gtk_text_buffer_move_mark")] move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter)320 fn move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter); 321 322 #[doc(alias = "gtk_text_buffer_move_mark_by_name")] move_mark_by_name(&self, name: &str, where_: &TextIter)323 fn move_mark_by_name(&self, name: &str, where_: &TextIter); 324 325 #[doc(alias = "gtk_text_buffer_paste_clipboard")] paste_clipboard( &self, clipboard: &Clipboard, override_location: Option<&TextIter>, default_editable: bool, )326 fn paste_clipboard( 327 &self, 328 clipboard: &Clipboard, 329 override_location: Option<&TextIter>, 330 default_editable: bool, 331 ); 332 333 #[doc(alias = "gtk_text_buffer_place_cursor")] place_cursor(&self, where_: &TextIter)334 fn place_cursor(&self, where_: &TextIter); 335 336 //#[doc(alias = "gtk_text_buffer_register_deserialize_format")] 337 //fn register_deserialize_format<P: Fn(&TextBuffer, &TextBuffer, &TextIter, &Vec<u8>, usize, bool, Option<&glib::Error>) -> bool + 'static>(&self, mime_type: &str, function: P) -> Option<gdk::Atom>; 338 339 #[doc(alias = "gtk_text_buffer_register_deserialize_tagset")] register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom340 fn register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom; 341 342 #[doc(alias = "gtk_text_buffer_register_serialize_tagset")] register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom343 fn register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom; 344 345 #[doc(alias = "gtk_text_buffer_remove_all_tags")] remove_all_tags(&self, start: &TextIter, end: &TextIter)346 fn remove_all_tags(&self, start: &TextIter, end: &TextIter); 347 348 #[doc(alias = "gtk_text_buffer_remove_selection_clipboard")] remove_selection_clipboard(&self, clipboard: &Clipboard)349 fn remove_selection_clipboard(&self, clipboard: &Clipboard); 350 351 #[doc(alias = "gtk_text_buffer_remove_tag")] remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter)352 fn remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter); 353 354 #[doc(alias = "gtk_text_buffer_remove_tag_by_name")] remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)355 fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter); 356 357 #[doc(alias = "gtk_text_buffer_select_range")] select_range(&self, ins: &TextIter, bound: &TextIter)358 fn select_range(&self, ins: &TextIter, bound: &TextIter); 359 360 #[doc(alias = "gtk_text_buffer_serialize")] serialize<P: IsA<TextBuffer>>( &self, content_buffer: &P, format: &gdk::Atom, start: &TextIter, end: &TextIter, ) -> Vec<u8>361 fn serialize<P: IsA<TextBuffer>>( 362 &self, 363 content_buffer: &P, 364 format: &gdk::Atom, 365 start: &TextIter, 366 end: &TextIter, 367 ) -> Vec<u8>; 368 369 #[doc(alias = "gtk_text_buffer_set_modified")] set_modified(&self, setting: bool)370 fn set_modified(&self, setting: bool); 371 372 #[doc(alias = "gtk_text_buffer_set_text")] set_text(&self, text: &str)373 fn set_text(&self, text: &str); 374 375 #[doc(alias = "gtk_text_buffer_unregister_deserialize_format")] unregister_deserialize_format(&self, format: &gdk::Atom)376 fn unregister_deserialize_format(&self, format: &gdk::Atom); 377 378 #[doc(alias = "gtk_text_buffer_unregister_serialize_format")] unregister_serialize_format(&self, format: &gdk::Atom)379 fn unregister_serialize_format(&self, format: &gdk::Atom); 380 381 #[doc(alias = "cursor-position")] cursor_position(&self) -> i32382 fn cursor_position(&self) -> i32; 383 384 #[doc(alias = "begin-user-action")] connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId385 fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 386 387 #[doc(alias = "changed")] connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId388 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 389 390 #[doc(alias = "end-user-action")] connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId391 fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 392 393 #[doc(alias = "mark-deleted")] connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId394 fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId; 395 396 #[doc(alias = "mark-set")] connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>( &self, f: F, ) -> SignalHandlerId397 fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>( 398 &self, 399 f: F, 400 ) -> SignalHandlerId; 401 402 #[doc(alias = "modified-changed")] connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId403 fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 404 405 #[doc(alias = "paste-done")] connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId406 fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId; 407 408 #[doc(alias = "copy-target-list")] connect_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId409 fn connect_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 410 411 #[doc(alias = "cursor-position")] connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId412 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 413 414 #[doc(alias = "has-selection")] connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId415 fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 416 417 #[doc(alias = "paste-target-list")] connect_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId418 fn connect_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 419 420 #[doc(alias = "text")] connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId421 fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 422 } 423 424 impl<O: IsA<TextBuffer>> TextBufferExt for O { add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter)425 fn add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter) { 426 unsafe { 427 ffi::gtk_text_buffer_add_mark( 428 self.as_ref().to_glib_none().0, 429 mark.as_ref().to_glib_none().0, 430 where_.to_glib_none().0, 431 ); 432 } 433 } 434 add_selection_clipboard(&self, clipboard: &Clipboard)435 fn add_selection_clipboard(&self, clipboard: &Clipboard) { 436 unsafe { 437 ffi::gtk_text_buffer_add_selection_clipboard( 438 self.as_ref().to_glib_none().0, 439 clipboard.to_glib_none().0, 440 ); 441 } 442 } 443 apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter)444 fn apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter) { 445 unsafe { 446 ffi::gtk_text_buffer_apply_tag( 447 self.as_ref().to_glib_none().0, 448 tag.as_ref().to_glib_none().0, 449 start.to_glib_none().0, 450 end.to_glib_none().0, 451 ); 452 } 453 } 454 apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)455 fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) { 456 unsafe { 457 ffi::gtk_text_buffer_apply_tag_by_name( 458 self.as_ref().to_glib_none().0, 459 name.to_glib_none().0, 460 start.to_glib_none().0, 461 end.to_glib_none().0, 462 ); 463 } 464 } 465 backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool466 fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool { 467 unsafe { 468 from_glib(ffi::gtk_text_buffer_backspace( 469 self.as_ref().to_glib_none().0, 470 iter.to_glib_none_mut().0, 471 interactive.into_glib(), 472 default_editable.into_glib(), 473 )) 474 } 475 } 476 begin_user_action(&self)477 fn begin_user_action(&self) { 478 unsafe { 479 ffi::gtk_text_buffer_begin_user_action(self.as_ref().to_glib_none().0); 480 } 481 } 482 copy_clipboard(&self, clipboard: &Clipboard)483 fn copy_clipboard(&self, clipboard: &Clipboard) { 484 unsafe { 485 ffi::gtk_text_buffer_copy_clipboard( 486 self.as_ref().to_glib_none().0, 487 clipboard.to_glib_none().0, 488 ); 489 } 490 } 491 create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor>492 fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor> { 493 unsafe { 494 from_glib_none(ffi::gtk_text_buffer_create_child_anchor( 495 self.as_ref().to_glib_none().0, 496 iter.to_glib_none_mut().0, 497 )) 498 } 499 } 500 create_mark( &self, mark_name: Option<&str>, where_: &TextIter, left_gravity: bool, ) -> Option<TextMark>501 fn create_mark( 502 &self, 503 mark_name: Option<&str>, 504 where_: &TextIter, 505 left_gravity: bool, 506 ) -> Option<TextMark> { 507 unsafe { 508 from_glib_none(ffi::gtk_text_buffer_create_mark( 509 self.as_ref().to_glib_none().0, 510 mark_name.to_glib_none().0, 511 where_.to_glib_none().0, 512 left_gravity.into_glib(), 513 )) 514 } 515 } 516 517 //fn create_tag(&self, tag_name: Option<&str>, first_property_name: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag> { 518 // unsafe { TODO: call ffi:gtk_text_buffer_create_tag() } 519 //} 520 cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool)521 fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool) { 522 unsafe { 523 ffi::gtk_text_buffer_cut_clipboard( 524 self.as_ref().to_glib_none().0, 525 clipboard.to_glib_none().0, 526 default_editable.into_glib(), 527 ); 528 } 529 } 530 delete(&self, start: &mut TextIter, end: &mut TextIter)531 fn delete(&self, start: &mut TextIter, end: &mut TextIter) { 532 unsafe { 533 ffi::gtk_text_buffer_delete( 534 self.as_ref().to_glib_none().0, 535 start.to_glib_none_mut().0, 536 end.to_glib_none_mut().0, 537 ); 538 } 539 } 540 delete_interactive( &self, start_iter: &mut TextIter, end_iter: &mut TextIter, default_editable: bool, ) -> bool541 fn delete_interactive( 542 &self, 543 start_iter: &mut TextIter, 544 end_iter: &mut TextIter, 545 default_editable: bool, 546 ) -> bool { 547 unsafe { 548 from_glib(ffi::gtk_text_buffer_delete_interactive( 549 self.as_ref().to_glib_none().0, 550 start_iter.to_glib_none_mut().0, 551 end_iter.to_glib_none_mut().0, 552 default_editable.into_glib(), 553 )) 554 } 555 } 556 delete_mark<P: IsA<TextMark>>(&self, mark: &P)557 fn delete_mark<P: IsA<TextMark>>(&self, mark: &P) { 558 unsafe { 559 ffi::gtk_text_buffer_delete_mark( 560 self.as_ref().to_glib_none().0, 561 mark.as_ref().to_glib_none().0, 562 ); 563 } 564 } 565 delete_mark_by_name(&self, name: &str)566 fn delete_mark_by_name(&self, name: &str) { 567 unsafe { 568 ffi::gtk_text_buffer_delete_mark_by_name( 569 self.as_ref().to_glib_none().0, 570 name.to_glib_none().0, 571 ); 572 } 573 } 574 delete_selection(&self, interactive: bool, default_editable: bool) -> bool575 fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool { 576 unsafe { 577 from_glib(ffi::gtk_text_buffer_delete_selection( 578 self.as_ref().to_glib_none().0, 579 interactive.into_glib(), 580 default_editable.into_glib(), 581 )) 582 } 583 } 584 deserialize<P: IsA<TextBuffer>>( &self, content_buffer: &P, format: &gdk::Atom, iter: &mut TextIter, data: &[u8], ) -> Result<(), glib::Error>585 fn deserialize<P: IsA<TextBuffer>>( 586 &self, 587 content_buffer: &P, 588 format: &gdk::Atom, 589 iter: &mut TextIter, 590 data: &[u8], 591 ) -> Result<(), glib::Error> { 592 let length = data.len() as usize; 593 unsafe { 594 let mut error = ptr::null_mut(); 595 let _ = ffi::gtk_text_buffer_deserialize( 596 self.as_ref().to_glib_none().0, 597 content_buffer.as_ref().to_glib_none().0, 598 format.to_glib_none().0, 599 iter.to_glib_none_mut().0, 600 data.to_glib_none().0, 601 length, 602 &mut error, 603 ); 604 if error.is_null() { 605 Ok(()) 606 } else { 607 Err(from_glib_full(error)) 608 } 609 } 610 } 611 deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool612 fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool { 613 unsafe { 614 from_glib(ffi::gtk_text_buffer_deserialize_get_can_create_tags( 615 self.as_ref().to_glib_none().0, 616 format.to_glib_none().0, 617 )) 618 } 619 } 620 deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool)621 fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool) { 622 unsafe { 623 ffi::gtk_text_buffer_deserialize_set_can_create_tags( 624 self.as_ref().to_glib_none().0, 625 format.to_glib_none().0, 626 can_create_tags.into_glib(), 627 ); 628 } 629 } 630 end_user_action(&self)631 fn end_user_action(&self) { 632 unsafe { 633 ffi::gtk_text_buffer_end_user_action(self.as_ref().to_glib_none().0); 634 } 635 } 636 bounds(&self) -> (TextIter, TextIter)637 fn bounds(&self) -> (TextIter, TextIter) { 638 unsafe { 639 let mut start = TextIter::uninitialized(); 640 let mut end = TextIter::uninitialized(); 641 ffi::gtk_text_buffer_get_bounds( 642 self.as_ref().to_glib_none().0, 643 start.to_glib_none_mut().0, 644 end.to_glib_none_mut().0, 645 ); 646 (start, end) 647 } 648 } 649 char_count(&self) -> i32650 fn char_count(&self) -> i32 { 651 unsafe { ffi::gtk_text_buffer_get_char_count(self.as_ref().to_glib_none().0) } 652 } 653 copy_target_list(&self) -> Option<TargetList>654 fn copy_target_list(&self) -> Option<TargetList> { 655 unsafe { 656 from_glib_none(ffi::gtk_text_buffer_get_copy_target_list( 657 self.as_ref().to_glib_none().0, 658 )) 659 } 660 } 661 deserialize_formats(&self) -> Vec<gdk::Atom>662 fn deserialize_formats(&self) -> Vec<gdk::Atom> { 663 unsafe { 664 let mut n_formats = mem::MaybeUninit::uninit(); 665 let ret = FromGlibContainer::from_glib_container_num( 666 ffi::gtk_text_buffer_get_deserialize_formats( 667 self.as_ref().to_glib_none().0, 668 n_formats.as_mut_ptr(), 669 ), 670 n_formats.assume_init() as usize, 671 ); 672 ret 673 } 674 } 675 end_iter(&self) -> TextIter676 fn end_iter(&self) -> TextIter { 677 unsafe { 678 let mut iter = TextIter::uninitialized(); 679 ffi::gtk_text_buffer_get_end_iter( 680 self.as_ref().to_glib_none().0, 681 iter.to_glib_none_mut().0, 682 ); 683 iter 684 } 685 } 686 has_selection(&self) -> bool687 fn has_selection(&self) -> bool { 688 unsafe { 689 from_glib(ffi::gtk_text_buffer_get_has_selection( 690 self.as_ref().to_glib_none().0, 691 )) 692 } 693 } 694 get_insert(&self) -> Option<TextMark>695 fn get_insert(&self) -> Option<TextMark> { 696 unsafe { 697 from_glib_none(ffi::gtk_text_buffer_get_insert( 698 self.as_ref().to_glib_none().0, 699 )) 700 } 701 } 702 iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter703 fn iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter { 704 unsafe { 705 let mut iter = TextIter::uninitialized(); 706 ffi::gtk_text_buffer_get_iter_at_child_anchor( 707 self.as_ref().to_glib_none().0, 708 iter.to_glib_none_mut().0, 709 anchor.as_ref().to_glib_none().0, 710 ); 711 iter 712 } 713 } 714 iter_at_line(&self, line_number: i32) -> TextIter715 fn iter_at_line(&self, line_number: i32) -> TextIter { 716 unsafe { 717 let mut iter = TextIter::uninitialized(); 718 ffi::gtk_text_buffer_get_iter_at_line( 719 self.as_ref().to_glib_none().0, 720 iter.to_glib_none_mut().0, 721 line_number, 722 ); 723 iter 724 } 725 } 726 iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter727 fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter { 728 unsafe { 729 let mut iter = TextIter::uninitialized(); 730 ffi::gtk_text_buffer_get_iter_at_line_index( 731 self.as_ref().to_glib_none().0, 732 iter.to_glib_none_mut().0, 733 line_number, 734 byte_index, 735 ); 736 iter 737 } 738 } 739 iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter740 fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter { 741 unsafe { 742 let mut iter = TextIter::uninitialized(); 743 ffi::gtk_text_buffer_get_iter_at_line_offset( 744 self.as_ref().to_glib_none().0, 745 iter.to_glib_none_mut().0, 746 line_number, 747 char_offset, 748 ); 749 iter 750 } 751 } 752 iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter753 fn iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter { 754 unsafe { 755 let mut iter = TextIter::uninitialized(); 756 ffi::gtk_text_buffer_get_iter_at_mark( 757 self.as_ref().to_glib_none().0, 758 iter.to_glib_none_mut().0, 759 mark.as_ref().to_glib_none().0, 760 ); 761 iter 762 } 763 } 764 iter_at_offset(&self, char_offset: i32) -> TextIter765 fn iter_at_offset(&self, char_offset: i32) -> TextIter { 766 unsafe { 767 let mut iter = TextIter::uninitialized(); 768 ffi::gtk_text_buffer_get_iter_at_offset( 769 self.as_ref().to_glib_none().0, 770 iter.to_glib_none_mut().0, 771 char_offset, 772 ); 773 iter 774 } 775 } 776 line_count(&self) -> i32777 fn line_count(&self) -> i32 { 778 unsafe { ffi::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) } 779 } 780 mark(&self, name: &str) -> Option<TextMark>781 fn mark(&self, name: &str) -> Option<TextMark> { 782 unsafe { 783 from_glib_none(ffi::gtk_text_buffer_get_mark( 784 self.as_ref().to_glib_none().0, 785 name.to_glib_none().0, 786 )) 787 } 788 } 789 is_modified(&self) -> bool790 fn is_modified(&self) -> bool { 791 unsafe { 792 from_glib(ffi::gtk_text_buffer_get_modified( 793 self.as_ref().to_glib_none().0, 794 )) 795 } 796 } 797 paste_target_list(&self) -> Option<TargetList>798 fn paste_target_list(&self) -> Option<TargetList> { 799 unsafe { 800 from_glib_none(ffi::gtk_text_buffer_get_paste_target_list( 801 self.as_ref().to_glib_none().0, 802 )) 803 } 804 } 805 selection_bound(&self) -> Option<TextMark>806 fn selection_bound(&self) -> Option<TextMark> { 807 unsafe { 808 from_glib_none(ffi::gtk_text_buffer_get_selection_bound( 809 self.as_ref().to_glib_none().0, 810 )) 811 } 812 } 813 selection_bounds(&self) -> Option<(TextIter, TextIter)>814 fn selection_bounds(&self) -> Option<(TextIter, TextIter)> { 815 unsafe { 816 let mut start = TextIter::uninitialized(); 817 let mut end = TextIter::uninitialized(); 818 let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds( 819 self.as_ref().to_glib_none().0, 820 start.to_glib_none_mut().0, 821 end.to_glib_none_mut().0, 822 )); 823 if ret { 824 Some((start, end)) 825 } else { 826 None 827 } 828 } 829 } 830 serialize_formats(&self) -> Vec<gdk::Atom>831 fn serialize_formats(&self) -> Vec<gdk::Atom> { 832 unsafe { 833 let mut n_formats = mem::MaybeUninit::uninit(); 834 let ret = FromGlibContainer::from_glib_container_num( 835 ffi::gtk_text_buffer_get_serialize_formats( 836 self.as_ref().to_glib_none().0, 837 n_formats.as_mut_ptr(), 838 ), 839 n_formats.assume_init() as usize, 840 ); 841 ret 842 } 843 } 844 slice( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> Option<glib::GString>845 fn slice( 846 &self, 847 start: &TextIter, 848 end: &TextIter, 849 include_hidden_chars: bool, 850 ) -> Option<glib::GString> { 851 unsafe { 852 from_glib_full(ffi::gtk_text_buffer_get_slice( 853 self.as_ref().to_glib_none().0, 854 start.to_glib_none().0, 855 end.to_glib_none().0, 856 include_hidden_chars.into_glib(), 857 )) 858 } 859 } 860 start_iter(&self) -> TextIter861 fn start_iter(&self) -> TextIter { 862 unsafe { 863 let mut iter = TextIter::uninitialized(); 864 ffi::gtk_text_buffer_get_start_iter( 865 self.as_ref().to_glib_none().0, 866 iter.to_glib_none_mut().0, 867 ); 868 iter 869 } 870 } 871 tag_table(&self) -> Option<TextTagTable>872 fn tag_table(&self) -> Option<TextTagTable> { 873 unsafe { 874 from_glib_none(ffi::gtk_text_buffer_get_tag_table( 875 self.as_ref().to_glib_none().0, 876 )) 877 } 878 } 879 text( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> Option<glib::GString>880 fn text( 881 &self, 882 start: &TextIter, 883 end: &TextIter, 884 include_hidden_chars: bool, 885 ) -> Option<glib::GString> { 886 unsafe { 887 from_glib_full(ffi::gtk_text_buffer_get_text( 888 self.as_ref().to_glib_none().0, 889 start.to_glib_none().0, 890 end.to_glib_none().0, 891 include_hidden_chars.into_glib(), 892 )) 893 } 894 } 895 insert(&self, iter: &mut TextIter, text: &str)896 fn insert(&self, iter: &mut TextIter, text: &str) { 897 let len = text.len() as i32; 898 unsafe { 899 ffi::gtk_text_buffer_insert( 900 self.as_ref().to_glib_none().0, 901 iter.to_glib_none_mut().0, 902 text.to_glib_none().0, 903 len, 904 ); 905 } 906 } 907 insert_at_cursor(&self, text: &str)908 fn insert_at_cursor(&self, text: &str) { 909 let len = text.len() as i32; 910 unsafe { 911 ffi::gtk_text_buffer_insert_at_cursor( 912 self.as_ref().to_glib_none().0, 913 text.to_glib_none().0, 914 len, 915 ); 916 } 917 } 918 insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P)919 fn insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P) { 920 unsafe { 921 ffi::gtk_text_buffer_insert_child_anchor( 922 self.as_ref().to_glib_none().0, 923 iter.to_glib_none_mut().0, 924 anchor.as_ref().to_glib_none().0, 925 ); 926 } 927 } 928 insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool929 fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool { 930 let len = text.len() as i32; 931 unsafe { 932 from_glib(ffi::gtk_text_buffer_insert_interactive( 933 self.as_ref().to_glib_none().0, 934 iter.to_glib_none_mut().0, 935 text.to_glib_none().0, 936 len, 937 default_editable.into_glib(), 938 )) 939 } 940 } 941 insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool942 fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool { 943 let len = text.len() as i32; 944 unsafe { 945 from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor( 946 self.as_ref().to_glib_none().0, 947 text.to_glib_none().0, 948 len, 949 default_editable.into_glib(), 950 )) 951 } 952 } 953 insert_markup(&self, iter: &mut TextIter, markup: &str)954 fn insert_markup(&self, iter: &mut TextIter, markup: &str) { 955 let len = markup.len() as i32; 956 unsafe { 957 ffi::gtk_text_buffer_insert_markup( 958 self.as_ref().to_glib_none().0, 959 iter.to_glib_none_mut().0, 960 markup.to_glib_none().0, 961 len, 962 ); 963 } 964 } 965 insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf)966 fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf) { 967 unsafe { 968 ffi::gtk_text_buffer_insert_pixbuf( 969 self.as_ref().to_glib_none().0, 970 iter.to_glib_none_mut().0, 971 pixbuf.to_glib_none().0, 972 ); 973 } 974 } 975 insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter)976 fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) { 977 unsafe { 978 ffi::gtk_text_buffer_insert_range( 979 self.as_ref().to_glib_none().0, 980 iter.to_glib_none_mut().0, 981 start.to_glib_none().0, 982 end.to_glib_none().0, 983 ); 984 } 985 } 986 insert_range_interactive( &self, iter: &mut TextIter, start: &TextIter, end: &TextIter, default_editable: bool, ) -> bool987 fn insert_range_interactive( 988 &self, 989 iter: &mut TextIter, 990 start: &TextIter, 991 end: &TextIter, 992 default_editable: bool, 993 ) -> bool { 994 unsafe { 995 from_glib(ffi::gtk_text_buffer_insert_range_interactive( 996 self.as_ref().to_glib_none().0, 997 iter.to_glib_none_mut().0, 998 start.to_glib_none().0, 999 end.to_glib_none().0, 1000 default_editable.into_glib(), 1001 )) 1002 } 1003 } 1004 1005 //fn insert_with_tags<P: IsA<TextTag>>(&self, iter: &mut TextIter, text: &str, first_tag: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { 1006 // unsafe { TODO: call ffi:gtk_text_buffer_insert_with_tags() } 1007 //} 1008 1009 //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { 1010 // unsafe { TODO: call ffi:gtk_text_buffer_insert_with_tags_by_name() } 1011 //} 1012 move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter)1013 fn move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter) { 1014 unsafe { 1015 ffi::gtk_text_buffer_move_mark( 1016 self.as_ref().to_glib_none().0, 1017 mark.as_ref().to_glib_none().0, 1018 where_.to_glib_none().0, 1019 ); 1020 } 1021 } 1022 move_mark_by_name(&self, name: &str, where_: &TextIter)1023 fn move_mark_by_name(&self, name: &str, where_: &TextIter) { 1024 unsafe { 1025 ffi::gtk_text_buffer_move_mark_by_name( 1026 self.as_ref().to_glib_none().0, 1027 name.to_glib_none().0, 1028 where_.to_glib_none().0, 1029 ); 1030 } 1031 } 1032 paste_clipboard( &self, clipboard: &Clipboard, override_location: Option<&TextIter>, default_editable: bool, )1033 fn paste_clipboard( 1034 &self, 1035 clipboard: &Clipboard, 1036 override_location: Option<&TextIter>, 1037 default_editable: bool, 1038 ) { 1039 unsafe { 1040 ffi::gtk_text_buffer_paste_clipboard( 1041 self.as_ref().to_glib_none().0, 1042 clipboard.to_glib_none().0, 1043 mut_override(override_location.to_glib_none().0), 1044 default_editable.into_glib(), 1045 ); 1046 } 1047 } 1048 place_cursor(&self, where_: &TextIter)1049 fn place_cursor(&self, where_: &TextIter) { 1050 unsafe { 1051 ffi::gtk_text_buffer_place_cursor( 1052 self.as_ref().to_glib_none().0, 1053 where_.to_glib_none().0, 1054 ); 1055 } 1056 } 1057 1058 //fn register_deserialize_format<P: Fn(&TextBuffer, &TextBuffer, &TextIter, &Vec<u8>, usize, bool, Option<&glib::Error>) -> bool + 'static>(&self, mime_type: &str, function: P) -> Option<gdk::Atom> { 1059 // unsafe { TODO: call ffi:gtk_text_buffer_register_deserialize_format() } 1060 //} 1061 register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom1062 fn register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom { 1063 unsafe { 1064 from_glib_none(ffi::gtk_text_buffer_register_deserialize_tagset( 1065 self.as_ref().to_glib_none().0, 1066 tagset_name.to_glib_none().0, 1067 )) 1068 } 1069 } 1070 register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom1071 fn register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom { 1072 unsafe { 1073 from_glib_none(ffi::gtk_text_buffer_register_serialize_tagset( 1074 self.as_ref().to_glib_none().0, 1075 tagset_name.to_glib_none().0, 1076 )) 1077 } 1078 } 1079 remove_all_tags(&self, start: &TextIter, end: &TextIter)1080 fn remove_all_tags(&self, start: &TextIter, end: &TextIter) { 1081 unsafe { 1082 ffi::gtk_text_buffer_remove_all_tags( 1083 self.as_ref().to_glib_none().0, 1084 start.to_glib_none().0, 1085 end.to_glib_none().0, 1086 ); 1087 } 1088 } 1089 remove_selection_clipboard(&self, clipboard: &Clipboard)1090 fn remove_selection_clipboard(&self, clipboard: &Clipboard) { 1091 unsafe { 1092 ffi::gtk_text_buffer_remove_selection_clipboard( 1093 self.as_ref().to_glib_none().0, 1094 clipboard.to_glib_none().0, 1095 ); 1096 } 1097 } 1098 remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter)1099 fn remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter) { 1100 unsafe { 1101 ffi::gtk_text_buffer_remove_tag( 1102 self.as_ref().to_glib_none().0, 1103 tag.as_ref().to_glib_none().0, 1104 start.to_glib_none().0, 1105 end.to_glib_none().0, 1106 ); 1107 } 1108 } 1109 remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)1110 fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) { 1111 unsafe { 1112 ffi::gtk_text_buffer_remove_tag_by_name( 1113 self.as_ref().to_glib_none().0, 1114 name.to_glib_none().0, 1115 start.to_glib_none().0, 1116 end.to_glib_none().0, 1117 ); 1118 } 1119 } 1120 select_range(&self, ins: &TextIter, bound: &TextIter)1121 fn select_range(&self, ins: &TextIter, bound: &TextIter) { 1122 unsafe { 1123 ffi::gtk_text_buffer_select_range( 1124 self.as_ref().to_glib_none().0, 1125 ins.to_glib_none().0, 1126 bound.to_glib_none().0, 1127 ); 1128 } 1129 } 1130 serialize<P: IsA<TextBuffer>>( &self, content_buffer: &P, format: &gdk::Atom, start: &TextIter, end: &TextIter, ) -> Vec<u8>1131 fn serialize<P: IsA<TextBuffer>>( 1132 &self, 1133 content_buffer: &P, 1134 format: &gdk::Atom, 1135 start: &TextIter, 1136 end: &TextIter, 1137 ) -> Vec<u8> { 1138 unsafe { 1139 let mut length = mem::MaybeUninit::uninit(); 1140 let ret = FromGlibContainer::from_glib_full_num( 1141 ffi::gtk_text_buffer_serialize( 1142 self.as_ref().to_glib_none().0, 1143 content_buffer.as_ref().to_glib_none().0, 1144 format.to_glib_none().0, 1145 start.to_glib_none().0, 1146 end.to_glib_none().0, 1147 length.as_mut_ptr(), 1148 ), 1149 length.assume_init() as usize, 1150 ); 1151 ret 1152 } 1153 } 1154 set_modified(&self, setting: bool)1155 fn set_modified(&self, setting: bool) { 1156 unsafe { 1157 ffi::gtk_text_buffer_set_modified(self.as_ref().to_glib_none().0, setting.into_glib()); 1158 } 1159 } 1160 set_text(&self, text: &str)1161 fn set_text(&self, text: &str) { 1162 let len = text.len() as i32; 1163 unsafe { 1164 ffi::gtk_text_buffer_set_text( 1165 self.as_ref().to_glib_none().0, 1166 text.to_glib_none().0, 1167 len, 1168 ); 1169 } 1170 } 1171 unregister_deserialize_format(&self, format: &gdk::Atom)1172 fn unregister_deserialize_format(&self, format: &gdk::Atom) { 1173 unsafe { 1174 ffi::gtk_text_buffer_unregister_deserialize_format( 1175 self.as_ref().to_glib_none().0, 1176 format.to_glib_none().0, 1177 ); 1178 } 1179 } 1180 unregister_serialize_format(&self, format: &gdk::Atom)1181 fn unregister_serialize_format(&self, format: &gdk::Atom) { 1182 unsafe { 1183 ffi::gtk_text_buffer_unregister_serialize_format( 1184 self.as_ref().to_glib_none().0, 1185 format.to_glib_none().0, 1186 ); 1187 } 1188 } 1189 cursor_position(&self) -> i321190 fn cursor_position(&self) -> i32 { 1191 unsafe { 1192 let mut value = glib::Value::from_type(<i32 as StaticType>::static_type()); 1193 glib::gobject_ffi::g_object_get_property( 1194 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 1195 b"cursor-position\0".as_ptr() as *const _, 1196 value.to_glib_none_mut().0, 1197 ); 1198 value 1199 .get() 1200 .expect("Return Value for property `cursor-position` getter") 1201 } 1202 } 1203 connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1204 fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1205 unsafe extern "C" fn begin_user_action_trampoline< 1206 P: IsA<TextBuffer>, 1207 F: Fn(&P) + 'static, 1208 >( 1209 this: *mut ffi::GtkTextBuffer, 1210 f: glib::ffi::gpointer, 1211 ) { 1212 let f: &F = &*(f as *const F); 1213 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1214 } 1215 unsafe { 1216 let f: Box_<F> = Box_::new(f); 1217 connect_raw( 1218 self.as_ptr() as *mut _, 1219 b"begin-user-action\0".as_ptr() as *const _, 1220 Some(transmute::<_, unsafe extern "C" fn()>( 1221 begin_user_action_trampoline::<Self, F> as *const (), 1222 )), 1223 Box_::into_raw(f), 1224 ) 1225 } 1226 } 1227 connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1228 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1229 unsafe extern "C" fn changed_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>( 1230 this: *mut ffi::GtkTextBuffer, 1231 f: glib::ffi::gpointer, 1232 ) { 1233 let f: &F = &*(f as *const F); 1234 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1235 } 1236 unsafe { 1237 let f: Box_<F> = Box_::new(f); 1238 connect_raw( 1239 self.as_ptr() as *mut _, 1240 b"changed\0".as_ptr() as *const _, 1241 Some(transmute::<_, unsafe extern "C" fn()>( 1242 changed_trampoline::<Self, F> as *const (), 1243 )), 1244 Box_::into_raw(f), 1245 ) 1246 } 1247 } 1248 connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1249 fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1250 unsafe extern "C" fn end_user_action_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>( 1251 this: *mut ffi::GtkTextBuffer, 1252 f: glib::ffi::gpointer, 1253 ) { 1254 let f: &F = &*(f as *const F); 1255 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1256 } 1257 unsafe { 1258 let f: Box_<F> = Box_::new(f); 1259 connect_raw( 1260 self.as_ptr() as *mut _, 1261 b"end-user-action\0".as_ptr() as *const _, 1262 Some(transmute::<_, unsafe extern "C" fn()>( 1263 end_user_action_trampoline::<Self, F> as *const (), 1264 )), 1265 Box_::into_raw(f), 1266 ) 1267 } 1268 } 1269 connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId1270 fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId { 1271 unsafe extern "C" fn mark_deleted_trampoline< 1272 P: IsA<TextBuffer>, 1273 F: Fn(&P, &TextMark) + 'static, 1274 >( 1275 this: *mut ffi::GtkTextBuffer, 1276 mark: *mut ffi::GtkTextMark, 1277 f: glib::ffi::gpointer, 1278 ) { 1279 let f: &F = &*(f as *const F); 1280 f( 1281 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(), 1282 &from_glib_borrow(mark), 1283 ) 1284 } 1285 unsafe { 1286 let f: Box_<F> = Box_::new(f); 1287 connect_raw( 1288 self.as_ptr() as *mut _, 1289 b"mark-deleted\0".as_ptr() as *const _, 1290 Some(transmute::<_, unsafe extern "C" fn()>( 1291 mark_deleted_trampoline::<Self, F> as *const (), 1292 )), 1293 Box_::into_raw(f), 1294 ) 1295 } 1296 } 1297 connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>( &self, f: F, ) -> SignalHandlerId1298 fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>( 1299 &self, 1300 f: F, 1301 ) -> SignalHandlerId { 1302 unsafe extern "C" fn mark_set_trampoline< 1303 P: IsA<TextBuffer>, 1304 F: Fn(&P, &TextIter, &TextMark) + 'static, 1305 >( 1306 this: *mut ffi::GtkTextBuffer, 1307 location: *mut ffi::GtkTextIter, 1308 mark: *mut ffi::GtkTextMark, 1309 f: glib::ffi::gpointer, 1310 ) { 1311 let f: &F = &*(f as *const F); 1312 f( 1313 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(), 1314 &from_glib_borrow(location), 1315 &from_glib_borrow(mark), 1316 ) 1317 } 1318 unsafe { 1319 let f: Box_<F> = Box_::new(f); 1320 connect_raw( 1321 self.as_ptr() as *mut _, 1322 b"mark-set\0".as_ptr() as *const _, 1323 Some(transmute::<_, unsafe extern "C" fn()>( 1324 mark_set_trampoline::<Self, F> as *const (), 1325 )), 1326 Box_::into_raw(f), 1327 ) 1328 } 1329 } 1330 connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1331 fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1332 unsafe extern "C" fn modified_changed_trampoline< 1333 P: IsA<TextBuffer>, 1334 F: Fn(&P) + 'static, 1335 >( 1336 this: *mut ffi::GtkTextBuffer, 1337 f: glib::ffi::gpointer, 1338 ) { 1339 let f: &F = &*(f as *const F); 1340 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1341 } 1342 unsafe { 1343 let f: Box_<F> = Box_::new(f); 1344 connect_raw( 1345 self.as_ptr() as *mut _, 1346 b"modified-changed\0".as_ptr() as *const _, 1347 Some(transmute::<_, unsafe extern "C" fn()>( 1348 modified_changed_trampoline::<Self, F> as *const (), 1349 )), 1350 Box_::into_raw(f), 1351 ) 1352 } 1353 } 1354 connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId1355 fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId { 1356 unsafe extern "C" fn paste_done_trampoline< 1357 P: IsA<TextBuffer>, 1358 F: Fn(&P, &Clipboard) + 'static, 1359 >( 1360 this: *mut ffi::GtkTextBuffer, 1361 clipboard: *mut ffi::GtkClipboard, 1362 f: glib::ffi::gpointer, 1363 ) { 1364 let f: &F = &*(f as *const F); 1365 f( 1366 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(), 1367 &from_glib_borrow(clipboard), 1368 ) 1369 } 1370 unsafe { 1371 let f: Box_<F> = Box_::new(f); 1372 connect_raw( 1373 self.as_ptr() as *mut _, 1374 b"paste-done\0".as_ptr() as *const _, 1375 Some(transmute::<_, unsafe extern "C" fn()>( 1376 paste_done_trampoline::<Self, F> as *const (), 1377 )), 1378 Box_::into_raw(f), 1379 ) 1380 } 1381 } 1382 connect_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1383 fn connect_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1384 unsafe extern "C" fn notify_copy_target_list_trampoline< 1385 P: IsA<TextBuffer>, 1386 F: Fn(&P) + 'static, 1387 >( 1388 this: *mut ffi::GtkTextBuffer, 1389 _param_spec: glib::ffi::gpointer, 1390 f: glib::ffi::gpointer, 1391 ) { 1392 let f: &F = &*(f as *const F); 1393 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1394 } 1395 unsafe { 1396 let f: Box_<F> = Box_::new(f); 1397 connect_raw( 1398 self.as_ptr() as *mut _, 1399 b"notify::copy-target-list\0".as_ptr() as *const _, 1400 Some(transmute::<_, unsafe extern "C" fn()>( 1401 notify_copy_target_list_trampoline::<Self, F> as *const (), 1402 )), 1403 Box_::into_raw(f), 1404 ) 1405 } 1406 } 1407 connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1408 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1409 unsafe extern "C" fn notify_cursor_position_trampoline< 1410 P: IsA<TextBuffer>, 1411 F: Fn(&P) + 'static, 1412 >( 1413 this: *mut ffi::GtkTextBuffer, 1414 _param_spec: glib::ffi::gpointer, 1415 f: glib::ffi::gpointer, 1416 ) { 1417 let f: &F = &*(f as *const F); 1418 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1419 } 1420 unsafe { 1421 let f: Box_<F> = Box_::new(f); 1422 connect_raw( 1423 self.as_ptr() as *mut _, 1424 b"notify::cursor-position\0".as_ptr() as *const _, 1425 Some(transmute::<_, unsafe extern "C" fn()>( 1426 notify_cursor_position_trampoline::<Self, F> as *const (), 1427 )), 1428 Box_::into_raw(f), 1429 ) 1430 } 1431 } 1432 connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1433 fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1434 unsafe extern "C" fn notify_has_selection_trampoline< 1435 P: IsA<TextBuffer>, 1436 F: Fn(&P) + 'static, 1437 >( 1438 this: *mut ffi::GtkTextBuffer, 1439 _param_spec: glib::ffi::gpointer, 1440 f: glib::ffi::gpointer, 1441 ) { 1442 let f: &F = &*(f as *const F); 1443 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1444 } 1445 unsafe { 1446 let f: Box_<F> = Box_::new(f); 1447 connect_raw( 1448 self.as_ptr() as *mut _, 1449 b"notify::has-selection\0".as_ptr() as *const _, 1450 Some(transmute::<_, unsafe extern "C" fn()>( 1451 notify_has_selection_trampoline::<Self, F> as *const (), 1452 )), 1453 Box_::into_raw(f), 1454 ) 1455 } 1456 } 1457 connect_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1458 fn connect_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1459 unsafe extern "C" fn notify_paste_target_list_trampoline< 1460 P: IsA<TextBuffer>, 1461 F: Fn(&P) + 'static, 1462 >( 1463 this: *mut ffi::GtkTextBuffer, 1464 _param_spec: glib::ffi::gpointer, 1465 f: glib::ffi::gpointer, 1466 ) { 1467 let f: &F = &*(f as *const F); 1468 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1469 } 1470 unsafe { 1471 let f: Box_<F> = Box_::new(f); 1472 connect_raw( 1473 self.as_ptr() as *mut _, 1474 b"notify::paste-target-list\0".as_ptr() as *const _, 1475 Some(transmute::<_, unsafe extern "C" fn()>( 1476 notify_paste_target_list_trampoline::<Self, F> as *const (), 1477 )), 1478 Box_::into_raw(f), 1479 ) 1480 } 1481 } 1482 connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1483 fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1484 unsafe extern "C" fn notify_text_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>( 1485 this: *mut ffi::GtkTextBuffer, 1486 _param_spec: glib::ffi::gpointer, 1487 f: glib::ffi::gpointer, 1488 ) { 1489 let f: &F = &*(f as *const F); 1490 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref()) 1491 } 1492 unsafe { 1493 let f: Box_<F> = Box_::new(f); 1494 connect_raw( 1495 self.as_ptr() as *mut _, 1496 b"notify::text\0".as_ptr() as *const _, 1497 Some(transmute::<_, unsafe extern "C" fn()>( 1498 notify_text_trampoline::<Self, F> as *const (), 1499 )), 1500 Box_::into_raw(f), 1501 ) 1502 } 1503 } 1504 } 1505 1506 impl fmt::Display for TextBuffer { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result1507 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 1508 f.write_str("TextBuffer") 1509 } 1510 } 1511