1#[cfg(feature = "v4_14")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
7use crate::AccessibleText;
8use crate::{
9 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Editable, EntryBuffer,
10 InputHints, InputPurpose, LayoutManager, Overflow, Widget,
11};
12use glib::{
13 prelude::*,
14 signal::{connect_raw, SignalHandlerId},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_14")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
21glib::wrapper! {
22 #[doc(alias = "GtkText")]
23 pub struct Text(Object<ffi::GtkText>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleText, Editable;
24
25 match fn {
26 type_ => || ffi::gtk_text_get_type(),
27 }
28}
29
30#[cfg(not(any(feature = "v4_14")))]
31glib::wrapper! {
32 #[doc(alias = "GtkText")]
33 pub struct Text(Object<ffi::GtkText>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
34
35 match fn {
36 type_ => || ffi::gtk_text_get_type(),
37 }
38}
39
40impl Text {
41 #[doc(alias = "gtk_text_new")]
42 pub fn new() -> Text {
43 assert_initialized_main_thread!();
44 unsafe { Widget::from_glib_none(ffi::gtk_text_new()).unsafe_cast() }
45 }
46
47 #[doc(alias = "gtk_text_new_with_buffer")]
48 #[doc(alias = "new_with_buffer")]
49 pub fn with_buffer(buffer: &impl IsA<EntryBuffer>) -> Text {
50 skip_assert_initialized!();
51 unsafe {
52 Widget::from_glib_none(ffi::gtk_text_new_with_buffer(
53 buffer.as_ref().to_glib_none().0,
54 ))
55 .unsafe_cast()
56 }
57 }
58
59 pub fn builder() -> TextBuilder {
64 TextBuilder::new()
65 }
66
67 #[cfg(feature = "v4_4")]
68 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
69 #[doc(alias = "gtk_text_compute_cursor_extents")]
70 pub fn compute_cursor_extents(&self, position: usize) -> (graphene::Rect, graphene::Rect) {
71 unsafe {
72 let mut strong = graphene::Rect::uninitialized();
73 let mut weak = graphene::Rect::uninitialized();
74 ffi::gtk_text_compute_cursor_extents(
75 self.to_glib_none().0,
76 position,
77 strong.to_glib_none_mut().0,
78 weak.to_glib_none_mut().0,
79 );
80 (strong, weak)
81 }
82 }
83
84 #[doc(alias = "gtk_text_get_activates_default")]
85 #[doc(alias = "get_activates_default")]
86 #[doc(alias = "activates-default")]
87 pub fn activates_default(&self) -> bool {
88 unsafe { from_glib(ffi::gtk_text_get_activates_default(self.to_glib_none().0)) }
89 }
90
91 #[doc(alias = "gtk_text_get_attributes")]
92 #[doc(alias = "get_attributes")]
93 pub fn attributes(&self) -> Option<pango::AttrList> {
94 unsafe { from_glib_none(ffi::gtk_text_get_attributes(self.to_glib_none().0)) }
95 }
96
97 #[doc(alias = "gtk_text_get_buffer")]
98 #[doc(alias = "get_buffer")]
99 pub fn buffer(&self) -> EntryBuffer {
100 unsafe { from_glib_none(ffi::gtk_text_get_buffer(self.to_glib_none().0)) }
101 }
102
103 #[doc(alias = "gtk_text_get_enable_emoji_completion")]
104 #[doc(alias = "get_enable_emoji_completion")]
105 #[doc(alias = "enable-emoji-completion")]
106 pub fn enables_emoji_completion(&self) -> bool {
107 unsafe {
108 from_glib(ffi::gtk_text_get_enable_emoji_completion(
109 self.to_glib_none().0,
110 ))
111 }
112 }
113
114 #[doc(alias = "gtk_text_get_extra_menu")]
115 #[doc(alias = "get_extra_menu")]
116 #[doc(alias = "extra-menu")]
117 pub fn extra_menu(&self) -> Option<gio::MenuModel> {
118 unsafe { from_glib_none(ffi::gtk_text_get_extra_menu(self.to_glib_none().0)) }
119 }
120
121 #[doc(alias = "gtk_text_get_input_hints")]
122 #[doc(alias = "get_input_hints")]
123 #[doc(alias = "input-hints")]
124 pub fn input_hints(&self) -> InputHints {
125 unsafe { from_glib(ffi::gtk_text_get_input_hints(self.to_glib_none().0)) }
126 }
127
128 #[doc(alias = "gtk_text_get_input_purpose")]
129 #[doc(alias = "get_input_purpose")]
130 #[doc(alias = "input-purpose")]
131 pub fn input_purpose(&self) -> InputPurpose {
132 unsafe { from_glib(ffi::gtk_text_get_input_purpose(self.to_glib_none().0)) }
133 }
134
135 #[doc(alias = "gtk_text_get_invisible_char")]
136 #[doc(alias = "get_invisible_char")]
137 #[doc(alias = "invisible-char")]
138 pub fn invisible_char(&self) -> char {
139 unsafe {
140 std::convert::TryFrom::try_from(ffi::gtk_text_get_invisible_char(self.to_glib_none().0))
141 .expect("conversion from an invalid Unicode value attempted")
142 }
143 }
144
145 #[doc(alias = "gtk_text_get_max_length")]
146 #[doc(alias = "get_max_length")]
147 #[doc(alias = "max-length")]
148 pub fn max_length(&self) -> i32 {
149 unsafe { ffi::gtk_text_get_max_length(self.to_glib_none().0) }
150 }
151
152 #[doc(alias = "gtk_text_get_overwrite_mode")]
153 #[doc(alias = "get_overwrite_mode")]
154 #[doc(alias = "overwrite-mode")]
155 pub fn is_overwrite_mode(&self) -> bool {
156 unsafe { from_glib(ffi::gtk_text_get_overwrite_mode(self.to_glib_none().0)) }
157 }
158
159 #[doc(alias = "gtk_text_get_placeholder_text")]
160 #[doc(alias = "get_placeholder_text")]
161 #[doc(alias = "placeholder-text")]
162 pub fn placeholder_text(&self) -> Option<glib::GString> {
163 unsafe { from_glib_none(ffi::gtk_text_get_placeholder_text(self.to_glib_none().0)) }
164 }
165
166 #[doc(alias = "gtk_text_get_propagate_text_width")]
167 #[doc(alias = "get_propagate_text_width")]
168 #[doc(alias = "propagate-text-width")]
169 pub fn propagates_text_width(&self) -> bool {
170 unsafe {
171 from_glib(ffi::gtk_text_get_propagate_text_width(
172 self.to_glib_none().0,
173 ))
174 }
175 }
176
177 #[doc(alias = "gtk_text_get_tabs")]
178 #[doc(alias = "get_tabs")]
179 pub fn tabs(&self) -> Option<pango::TabArray> {
180 unsafe { from_glib_none(ffi::gtk_text_get_tabs(self.to_glib_none().0)) }
181 }
182
183 #[doc(alias = "gtk_text_get_text_length")]
184 #[doc(alias = "get_text_length")]
185 pub fn text_length(&self) -> u16 {
186 unsafe { ffi::gtk_text_get_text_length(self.to_glib_none().0) }
187 }
188
189 #[doc(alias = "gtk_text_get_truncate_multiline")]
190 #[doc(alias = "get_truncate_multiline")]
191 #[doc(alias = "truncate-multiline")]
192 pub fn must_truncate_multiline(&self) -> bool {
193 unsafe { from_glib(ffi::gtk_text_get_truncate_multiline(self.to_glib_none().0)) }
194 }
195
196 #[doc(alias = "gtk_text_get_visibility")]
197 #[doc(alias = "get_visibility")]
198 #[doc(alias = "visibility")]
199 pub fn is_visible(&self) -> bool {
200 unsafe { from_glib(ffi::gtk_text_get_visibility(self.to_glib_none().0)) }
201 }
202
203 #[doc(alias = "gtk_text_grab_focus_without_selecting")]
204 pub fn grab_focus_without_selecting(&self) -> bool {
205 unsafe {
206 from_glib(ffi::gtk_text_grab_focus_without_selecting(
207 self.to_glib_none().0,
208 ))
209 }
210 }
211
212 #[doc(alias = "gtk_text_set_activates_default")]
213 #[doc(alias = "activates-default")]
214 pub fn set_activates_default(&self, activates: bool) {
215 unsafe {
216 ffi::gtk_text_set_activates_default(self.to_glib_none().0, activates.into_glib());
217 }
218 }
219
220 #[doc(alias = "gtk_text_set_attributes")]
221 #[doc(alias = "attributes")]
222 pub fn set_attributes(&self, attrs: Option<&pango::AttrList>) {
223 unsafe {
224 ffi::gtk_text_set_attributes(self.to_glib_none().0, attrs.to_glib_none().0);
225 }
226 }
227
228 #[doc(alias = "gtk_text_set_buffer")]
229 #[doc(alias = "buffer")]
230 pub fn set_buffer(&self, buffer: &impl IsA<EntryBuffer>) {
231 unsafe {
232 ffi::gtk_text_set_buffer(self.to_glib_none().0, buffer.as_ref().to_glib_none().0);
233 }
234 }
235
236 #[doc(alias = "gtk_text_set_enable_emoji_completion")]
237 #[doc(alias = "enable-emoji-completion")]
238 pub fn set_enable_emoji_completion(&self, enable_emoji_completion: bool) {
239 unsafe {
240 ffi::gtk_text_set_enable_emoji_completion(
241 self.to_glib_none().0,
242 enable_emoji_completion.into_glib(),
243 );
244 }
245 }
246
247 #[doc(alias = "gtk_text_set_extra_menu")]
248 #[doc(alias = "extra-menu")]
249 pub fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
250 unsafe {
251 ffi::gtk_text_set_extra_menu(
252 self.to_glib_none().0,
253 model.map(|p| p.as_ref()).to_glib_none().0,
254 );
255 }
256 }
257
258 #[doc(alias = "gtk_text_set_input_hints")]
259 #[doc(alias = "input-hints")]
260 pub fn set_input_hints(&self, hints: InputHints) {
261 unsafe {
262 ffi::gtk_text_set_input_hints(self.to_glib_none().0, hints.into_glib());
263 }
264 }
265
266 #[doc(alias = "gtk_text_set_input_purpose")]
267 #[doc(alias = "input-purpose")]
268 pub fn set_input_purpose(&self, purpose: InputPurpose) {
269 unsafe {
270 ffi::gtk_text_set_input_purpose(self.to_glib_none().0, purpose.into_glib());
271 }
272 }
273
274 #[doc(alias = "gtk_text_set_invisible_char")]
275 #[doc(alias = "invisible-char")]
276 pub fn set_invisible_char(&self, ch: char) {
277 unsafe {
278 ffi::gtk_text_set_invisible_char(self.to_glib_none().0, ch.into_glib());
279 }
280 }
281
282 #[doc(alias = "gtk_text_set_max_length")]
283 #[doc(alias = "max-length")]
284 pub fn set_max_length(&self, length: i32) {
285 unsafe {
286 ffi::gtk_text_set_max_length(self.to_glib_none().0, length);
287 }
288 }
289
290 #[doc(alias = "gtk_text_set_overwrite_mode")]
291 #[doc(alias = "overwrite-mode")]
292 pub fn set_overwrite_mode(&self, overwrite: bool) {
293 unsafe {
294 ffi::gtk_text_set_overwrite_mode(self.to_glib_none().0, overwrite.into_glib());
295 }
296 }
297
298 #[doc(alias = "gtk_text_set_placeholder_text")]
299 #[doc(alias = "placeholder-text")]
300 pub fn set_placeholder_text(&self, text: Option<&str>) {
301 unsafe {
302 ffi::gtk_text_set_placeholder_text(self.to_glib_none().0, text.to_glib_none().0);
303 }
304 }
305
306 #[doc(alias = "gtk_text_set_propagate_text_width")]
307 #[doc(alias = "propagate-text-width")]
308 pub fn set_propagate_text_width(&self, propagate_text_width: bool) {
309 unsafe {
310 ffi::gtk_text_set_propagate_text_width(
311 self.to_glib_none().0,
312 propagate_text_width.into_glib(),
313 );
314 }
315 }
316
317 #[doc(alias = "gtk_text_set_tabs")]
318 #[doc(alias = "tabs")]
319 pub fn set_tabs(&self, tabs: Option<&pango::TabArray>) {
320 unsafe {
321 ffi::gtk_text_set_tabs(self.to_glib_none().0, mut_override(tabs.to_glib_none().0));
322 }
323 }
324
325 #[doc(alias = "gtk_text_set_truncate_multiline")]
326 #[doc(alias = "truncate-multiline")]
327 pub fn set_truncate_multiline(&self, truncate_multiline: bool) {
328 unsafe {
329 ffi::gtk_text_set_truncate_multiline(
330 self.to_glib_none().0,
331 truncate_multiline.into_glib(),
332 );
333 }
334 }
335
336 #[doc(alias = "gtk_text_set_visibility")]
337 #[doc(alias = "visibility")]
338 pub fn set_visibility(&self, visible: bool) {
339 unsafe {
340 ffi::gtk_text_set_visibility(self.to_glib_none().0, visible.into_glib());
341 }
342 }
343
344 #[doc(alias = "gtk_text_unset_invisible_char")]
345 pub fn unset_invisible_char(&self) {
346 unsafe {
347 ffi::gtk_text_unset_invisible_char(self.to_glib_none().0);
348 }
349 }
350
351 #[doc(alias = "im-module")]
352 pub fn im_module(&self) -> Option<glib::GString> {
353 ObjectExt::property(self, "im-module")
354 }
355
356 #[doc(alias = "im-module")]
357 pub fn set_im_module(&self, im_module: Option<&str>) {
358 ObjectExt::set_property(self, "im-module", im_module)
359 }
360
361 #[doc(alias = "invisible-char-set")]
362 pub fn is_invisible_char_set(&self) -> bool {
363 ObjectExt::property(self, "invisible-char-set")
364 }
365
366 #[doc(alias = "scroll-offset")]
367 pub fn scroll_offset(&self) -> i32 {
368 ObjectExt::property(self, "scroll-offset")
369 }
370
371 #[doc(alias = "activates-default")]
372 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
373 &self,
374 f: F,
375 ) -> SignalHandlerId {
376 unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&Text) + 'static>(
377 this: *mut ffi::GtkText,
378 _param_spec: glib::ffi::gpointer,
379 f: glib::ffi::gpointer,
380 ) {
381 let f: &F = &*(f as *const F);
382 f(&from_glib_borrow(this))
383 }
384 unsafe {
385 let f: Box_<F> = Box_::new(f);
386 connect_raw(
387 self.as_ptr() as *mut _,
388 c"notify::activates-default".as_ptr() as *const _,
389 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
390 notify_activates_default_trampoline::<F> as *const (),
391 )),
392 Box_::into_raw(f),
393 )
394 }
395 }
396
397 #[doc(alias = "attributes")]
398 pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
399 unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&Text) + 'static>(
400 this: *mut ffi::GtkText,
401 _param_spec: glib::ffi::gpointer,
402 f: glib::ffi::gpointer,
403 ) {
404 let f: &F = &*(f as *const F);
405 f(&from_glib_borrow(this))
406 }
407 unsafe {
408 let f: Box_<F> = Box_::new(f);
409 connect_raw(
410 self.as_ptr() as *mut _,
411 c"notify::attributes".as_ptr() as *const _,
412 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413 notify_attributes_trampoline::<F> as *const (),
414 )),
415 Box_::into_raw(f),
416 )
417 }
418 }
419
420 #[doc(alias = "buffer")]
421 pub fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
422 unsafe extern "C" fn notify_buffer_trampoline<F: Fn(&Text) + 'static>(
423 this: *mut ffi::GtkText,
424 _param_spec: glib::ffi::gpointer,
425 f: glib::ffi::gpointer,
426 ) {
427 let f: &F = &*(f as *const F);
428 f(&from_glib_borrow(this))
429 }
430 unsafe {
431 let f: Box_<F> = Box_::new(f);
432 connect_raw(
433 self.as_ptr() as *mut _,
434 c"notify::buffer".as_ptr() as *const _,
435 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
436 notify_buffer_trampoline::<F> as *const (),
437 )),
438 Box_::into_raw(f),
439 )
440 }
441 }
442
443 #[doc(alias = "enable-emoji-completion")]
444 pub fn connect_enable_emoji_completion_notify<F: Fn(&Self) + 'static>(
445 &self,
446 f: F,
447 ) -> SignalHandlerId {
448 unsafe extern "C" fn notify_enable_emoji_completion_trampoline<F: Fn(&Text) + 'static>(
449 this: *mut ffi::GtkText,
450 _param_spec: glib::ffi::gpointer,
451 f: glib::ffi::gpointer,
452 ) {
453 let f: &F = &*(f as *const F);
454 f(&from_glib_borrow(this))
455 }
456 unsafe {
457 let f: Box_<F> = Box_::new(f);
458 connect_raw(
459 self.as_ptr() as *mut _,
460 c"notify::enable-emoji-completion".as_ptr() as *const _,
461 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
462 notify_enable_emoji_completion_trampoline::<F> as *const (),
463 )),
464 Box_::into_raw(f),
465 )
466 }
467 }
468
469 #[doc(alias = "extra-menu")]
470 pub fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
471 unsafe extern "C" fn notify_extra_menu_trampoline<F: Fn(&Text) + 'static>(
472 this: *mut ffi::GtkText,
473 _param_spec: glib::ffi::gpointer,
474 f: glib::ffi::gpointer,
475 ) {
476 let f: &F = &*(f as *const F);
477 f(&from_glib_borrow(this))
478 }
479 unsafe {
480 let f: Box_<F> = Box_::new(f);
481 connect_raw(
482 self.as_ptr() as *mut _,
483 c"notify::extra-menu".as_ptr() as *const _,
484 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
485 notify_extra_menu_trampoline::<F> as *const (),
486 )),
487 Box_::into_raw(f),
488 )
489 }
490 }
491
492 #[doc(alias = "im-module")]
493 pub fn connect_im_module_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
494 unsafe extern "C" fn notify_im_module_trampoline<F: Fn(&Text) + 'static>(
495 this: *mut ffi::GtkText,
496 _param_spec: glib::ffi::gpointer,
497 f: glib::ffi::gpointer,
498 ) {
499 let f: &F = &*(f as *const F);
500 f(&from_glib_borrow(this))
501 }
502 unsafe {
503 let f: Box_<F> = Box_::new(f);
504 connect_raw(
505 self.as_ptr() as *mut _,
506 c"notify::im-module".as_ptr() as *const _,
507 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
508 notify_im_module_trampoline::<F> as *const (),
509 )),
510 Box_::into_raw(f),
511 )
512 }
513 }
514
515 #[doc(alias = "input-hints")]
516 pub fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517 unsafe extern "C" fn notify_input_hints_trampoline<F: Fn(&Text) + 'static>(
518 this: *mut ffi::GtkText,
519 _param_spec: glib::ffi::gpointer,
520 f: glib::ffi::gpointer,
521 ) {
522 let f: &F = &*(f as *const F);
523 f(&from_glib_borrow(this))
524 }
525 unsafe {
526 let f: Box_<F> = Box_::new(f);
527 connect_raw(
528 self.as_ptr() as *mut _,
529 c"notify::input-hints".as_ptr() as *const _,
530 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
531 notify_input_hints_trampoline::<F> as *const (),
532 )),
533 Box_::into_raw(f),
534 )
535 }
536 }
537
538 #[doc(alias = "input-purpose")]
539 pub fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
540 unsafe extern "C" fn notify_input_purpose_trampoline<F: Fn(&Text) + 'static>(
541 this: *mut ffi::GtkText,
542 _param_spec: glib::ffi::gpointer,
543 f: glib::ffi::gpointer,
544 ) {
545 let f: &F = &*(f as *const F);
546 f(&from_glib_borrow(this))
547 }
548 unsafe {
549 let f: Box_<F> = Box_::new(f);
550 connect_raw(
551 self.as_ptr() as *mut _,
552 c"notify::input-purpose".as_ptr() as *const _,
553 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
554 notify_input_purpose_trampoline::<F> as *const (),
555 )),
556 Box_::into_raw(f),
557 )
558 }
559 }
560
561 #[doc(alias = "invisible-char")]
562 pub fn connect_invisible_char_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
563 unsafe extern "C" fn notify_invisible_char_trampoline<F: Fn(&Text) + 'static>(
564 this: *mut ffi::GtkText,
565 _param_spec: glib::ffi::gpointer,
566 f: glib::ffi::gpointer,
567 ) {
568 let f: &F = &*(f as *const F);
569 f(&from_glib_borrow(this))
570 }
571 unsafe {
572 let f: Box_<F> = Box_::new(f);
573 connect_raw(
574 self.as_ptr() as *mut _,
575 c"notify::invisible-char".as_ptr() as *const _,
576 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577 notify_invisible_char_trampoline::<F> as *const (),
578 )),
579 Box_::into_raw(f),
580 )
581 }
582 }
583
584 #[doc(alias = "invisible-char-set")]
585 pub fn connect_invisible_char_set_notify<F: Fn(&Self) + 'static>(
586 &self,
587 f: F,
588 ) -> SignalHandlerId {
589 unsafe extern "C" fn notify_invisible_char_set_trampoline<F: Fn(&Text) + 'static>(
590 this: *mut ffi::GtkText,
591 _param_spec: glib::ffi::gpointer,
592 f: glib::ffi::gpointer,
593 ) {
594 let f: &F = &*(f as *const F);
595 f(&from_glib_borrow(this))
596 }
597 unsafe {
598 let f: Box_<F> = Box_::new(f);
599 connect_raw(
600 self.as_ptr() as *mut _,
601 c"notify::invisible-char-set".as_ptr() as *const _,
602 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
603 notify_invisible_char_set_trampoline::<F> as *const (),
604 )),
605 Box_::into_raw(f),
606 )
607 }
608 }
609
610 #[doc(alias = "max-length")]
611 pub fn connect_max_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
612 unsafe extern "C" fn notify_max_length_trampoline<F: Fn(&Text) + 'static>(
613 this: *mut ffi::GtkText,
614 _param_spec: glib::ffi::gpointer,
615 f: glib::ffi::gpointer,
616 ) {
617 let f: &F = &*(f as *const F);
618 f(&from_glib_borrow(this))
619 }
620 unsafe {
621 let f: Box_<F> = Box_::new(f);
622 connect_raw(
623 self.as_ptr() as *mut _,
624 c"notify::max-length".as_ptr() as *const _,
625 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
626 notify_max_length_trampoline::<F> as *const (),
627 )),
628 Box_::into_raw(f),
629 )
630 }
631 }
632
633 #[doc(alias = "overwrite-mode")]
634 pub fn connect_overwrite_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
635 unsafe extern "C" fn notify_overwrite_mode_trampoline<F: Fn(&Text) + 'static>(
636 this: *mut ffi::GtkText,
637 _param_spec: glib::ffi::gpointer,
638 f: glib::ffi::gpointer,
639 ) {
640 let f: &F = &*(f as *const F);
641 f(&from_glib_borrow(this))
642 }
643 unsafe {
644 let f: Box_<F> = Box_::new(f);
645 connect_raw(
646 self.as_ptr() as *mut _,
647 c"notify::overwrite-mode".as_ptr() as *const _,
648 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
649 notify_overwrite_mode_trampoline::<F> as *const (),
650 )),
651 Box_::into_raw(f),
652 )
653 }
654 }
655
656 #[doc(alias = "placeholder-text")]
657 pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
658 unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&Text) + 'static>(
659 this: *mut ffi::GtkText,
660 _param_spec: glib::ffi::gpointer,
661 f: glib::ffi::gpointer,
662 ) {
663 let f: &F = &*(f as *const F);
664 f(&from_glib_borrow(this))
665 }
666 unsafe {
667 let f: Box_<F> = Box_::new(f);
668 connect_raw(
669 self.as_ptr() as *mut _,
670 c"notify::placeholder-text".as_ptr() as *const _,
671 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
672 notify_placeholder_text_trampoline::<F> as *const (),
673 )),
674 Box_::into_raw(f),
675 )
676 }
677 }
678
679 #[doc(alias = "propagate-text-width")]
680 pub fn connect_propagate_text_width_notify<F: Fn(&Self) + 'static>(
681 &self,
682 f: F,
683 ) -> SignalHandlerId {
684 unsafe extern "C" fn notify_propagate_text_width_trampoline<F: Fn(&Text) + 'static>(
685 this: *mut ffi::GtkText,
686 _param_spec: glib::ffi::gpointer,
687 f: glib::ffi::gpointer,
688 ) {
689 let f: &F = &*(f as *const F);
690 f(&from_glib_borrow(this))
691 }
692 unsafe {
693 let f: Box_<F> = Box_::new(f);
694 connect_raw(
695 self.as_ptr() as *mut _,
696 c"notify::propagate-text-width".as_ptr() as *const _,
697 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
698 notify_propagate_text_width_trampoline::<F> as *const (),
699 )),
700 Box_::into_raw(f),
701 )
702 }
703 }
704
705 #[doc(alias = "scroll-offset")]
706 pub fn connect_scroll_offset_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
707 unsafe extern "C" fn notify_scroll_offset_trampoline<F: Fn(&Text) + 'static>(
708 this: *mut ffi::GtkText,
709 _param_spec: glib::ffi::gpointer,
710 f: glib::ffi::gpointer,
711 ) {
712 let f: &F = &*(f as *const F);
713 f(&from_glib_borrow(this))
714 }
715 unsafe {
716 let f: Box_<F> = Box_::new(f);
717 connect_raw(
718 self.as_ptr() as *mut _,
719 c"notify::scroll-offset".as_ptr() as *const _,
720 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
721 notify_scroll_offset_trampoline::<F> as *const (),
722 )),
723 Box_::into_raw(f),
724 )
725 }
726 }
727
728 #[doc(alias = "tabs")]
729 pub fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
730 unsafe extern "C" fn notify_tabs_trampoline<F: Fn(&Text) + 'static>(
731 this: *mut ffi::GtkText,
732 _param_spec: glib::ffi::gpointer,
733 f: glib::ffi::gpointer,
734 ) {
735 let f: &F = &*(f as *const F);
736 f(&from_glib_borrow(this))
737 }
738 unsafe {
739 let f: Box_<F> = Box_::new(f);
740 connect_raw(
741 self.as_ptr() as *mut _,
742 c"notify::tabs".as_ptr() as *const _,
743 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
744 notify_tabs_trampoline::<F> as *const (),
745 )),
746 Box_::into_raw(f),
747 )
748 }
749 }
750
751 #[doc(alias = "truncate-multiline")]
752 pub fn connect_truncate_multiline_notify<F: Fn(&Self) + 'static>(
753 &self,
754 f: F,
755 ) -> SignalHandlerId {
756 unsafe extern "C" fn notify_truncate_multiline_trampoline<F: Fn(&Text) + 'static>(
757 this: *mut ffi::GtkText,
758 _param_spec: glib::ffi::gpointer,
759 f: glib::ffi::gpointer,
760 ) {
761 let f: &F = &*(f as *const F);
762 f(&from_glib_borrow(this))
763 }
764 unsafe {
765 let f: Box_<F> = Box_::new(f);
766 connect_raw(
767 self.as_ptr() as *mut _,
768 c"notify::truncate-multiline".as_ptr() as *const _,
769 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
770 notify_truncate_multiline_trampoline::<F> as *const (),
771 )),
772 Box_::into_raw(f),
773 )
774 }
775 }
776
777 #[doc(alias = "visibility")]
778 pub fn connect_visibility_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
779 unsafe extern "C" fn notify_visibility_trampoline<F: Fn(&Text) + 'static>(
780 this: *mut ffi::GtkText,
781 _param_spec: glib::ffi::gpointer,
782 f: glib::ffi::gpointer,
783 ) {
784 let f: &F = &*(f as *const F);
785 f(&from_glib_borrow(this))
786 }
787 unsafe {
788 let f: Box_<F> = Box_::new(f);
789 connect_raw(
790 self.as_ptr() as *mut _,
791 c"notify::visibility".as_ptr() as *const _,
792 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
793 notify_visibility_trampoline::<F> as *const (),
794 )),
795 Box_::into_raw(f),
796 )
797 }
798 }
799}
800
801impl Default for Text {
802 fn default() -> Self {
803 Self::new()
804 }
805}
806
807#[must_use = "The builder must be built to be used"]
812pub struct TextBuilder {
813 builder: glib::object::ObjectBuilder<'static, Text>,
814}
815
816impl TextBuilder {
817 fn new() -> Self {
818 Self {
819 builder: glib::object::Object::builder(),
820 }
821 }
822
823 pub fn activates_default(self, activates_default: bool) -> Self {
824 Self {
825 builder: self
826 .builder
827 .property("activates-default", activates_default),
828 }
829 }
830
831 pub fn attributes(self, attributes: &pango::AttrList) -> Self {
832 Self {
833 builder: self.builder.property("attributes", attributes.clone()),
834 }
835 }
836
837 pub fn buffer(self, buffer: &impl IsA<EntryBuffer>) -> Self {
838 Self {
839 builder: self.builder.property("buffer", buffer.clone().upcast()),
840 }
841 }
842
843 pub fn enable_emoji_completion(self, enable_emoji_completion: bool) -> Self {
844 Self {
845 builder: self
846 .builder
847 .property("enable-emoji-completion", enable_emoji_completion),
848 }
849 }
850
851 pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
852 Self {
853 builder: self
854 .builder
855 .property("extra-menu", extra_menu.clone().upcast()),
856 }
857 }
858
859 pub fn im_module(self, im_module: impl Into<glib::GString>) -> Self {
860 Self {
861 builder: self.builder.property("im-module", im_module.into()),
862 }
863 }
864
865 pub fn input_hints(self, input_hints: InputHints) -> Self {
866 Self {
867 builder: self.builder.property("input-hints", input_hints),
868 }
869 }
870
871 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
872 Self {
873 builder: self.builder.property("input-purpose", input_purpose),
874 }
875 }
876
877 pub fn invisible_char(self, invisible_char: u32) -> Self {
878 Self {
879 builder: self.builder.property("invisible-char", invisible_char),
880 }
881 }
882
883 pub fn invisible_char_set(self, invisible_char_set: bool) -> Self {
884 Self {
885 builder: self
886 .builder
887 .property("invisible-char-set", invisible_char_set),
888 }
889 }
890
891 pub fn max_length(self, max_length: i32) -> Self {
892 Self {
893 builder: self.builder.property("max-length", max_length),
894 }
895 }
896
897 pub fn overwrite_mode(self, overwrite_mode: bool) -> Self {
898 Self {
899 builder: self.builder.property("overwrite-mode", overwrite_mode),
900 }
901 }
902
903 pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
904 Self {
905 builder: self
906 .builder
907 .property("placeholder-text", placeholder_text.into()),
908 }
909 }
910
911 pub fn propagate_text_width(self, propagate_text_width: bool) -> Self {
912 Self {
913 builder: self
914 .builder
915 .property("propagate-text-width", propagate_text_width),
916 }
917 }
918
919 pub fn tabs(self, tabs: &pango::TabArray) -> Self {
920 Self {
921 builder: self.builder.property("tabs", tabs),
922 }
923 }
924
925 pub fn truncate_multiline(self, truncate_multiline: bool) -> Self {
926 Self {
927 builder: self
928 .builder
929 .property("truncate-multiline", truncate_multiline),
930 }
931 }
932
933 pub fn visibility(self, visibility: bool) -> Self {
934 Self {
935 builder: self.builder.property("visibility", visibility),
936 }
937 }
938
939 pub fn can_focus(self, can_focus: bool) -> Self {
940 Self {
941 builder: self.builder.property("can-focus", can_focus),
942 }
943 }
944
945 pub fn can_target(self, can_target: bool) -> Self {
946 Self {
947 builder: self.builder.property("can-target", can_target),
948 }
949 }
950
951 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
952 Self {
953 builder: self.builder.property("css-classes", css_classes.into()),
954 }
955 }
956
957 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
958 Self {
959 builder: self.builder.property("css-name", css_name.into()),
960 }
961 }
962
963 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
964 Self {
965 builder: self.builder.property("cursor", cursor.clone()),
966 }
967 }
968
969 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
970 Self {
971 builder: self.builder.property("focus-on-click", focus_on_click),
972 }
973 }
974
975 pub fn focusable(self, focusable: bool) -> Self {
976 Self {
977 builder: self.builder.property("focusable", focusable),
978 }
979 }
980
981 pub fn halign(self, halign: Align) -> Self {
982 Self {
983 builder: self.builder.property("halign", halign),
984 }
985 }
986
987 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
988 Self {
989 builder: self.builder.property("has-tooltip", has_tooltip),
990 }
991 }
992
993 pub fn height_request(self, height_request: i32) -> Self {
994 Self {
995 builder: self.builder.property("height-request", height_request),
996 }
997 }
998
999 pub fn hexpand(self, hexpand: bool) -> Self {
1000 Self {
1001 builder: self.builder.property("hexpand", hexpand),
1002 }
1003 }
1004
1005 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1006 Self {
1007 builder: self.builder.property("hexpand-set", hexpand_set),
1008 }
1009 }
1010
1011 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1012 Self {
1013 builder: self
1014 .builder
1015 .property("layout-manager", layout_manager.clone().upcast()),
1016 }
1017 }
1018
1019 #[cfg(feature = "v4_18")]
1020 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1021 pub fn limit_events(self, limit_events: bool) -> Self {
1022 Self {
1023 builder: self.builder.property("limit-events", limit_events),
1024 }
1025 }
1026
1027 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1028 Self {
1029 builder: self.builder.property("margin-bottom", margin_bottom),
1030 }
1031 }
1032
1033 pub fn margin_end(self, margin_end: i32) -> Self {
1034 Self {
1035 builder: self.builder.property("margin-end", margin_end),
1036 }
1037 }
1038
1039 pub fn margin_start(self, margin_start: i32) -> Self {
1040 Self {
1041 builder: self.builder.property("margin-start", margin_start),
1042 }
1043 }
1044
1045 pub fn margin_top(self, margin_top: i32) -> Self {
1046 Self {
1047 builder: self.builder.property("margin-top", margin_top),
1048 }
1049 }
1050
1051 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1052 Self {
1053 builder: self.builder.property("name", name.into()),
1054 }
1055 }
1056
1057 pub fn opacity(self, opacity: f64) -> Self {
1058 Self {
1059 builder: self.builder.property("opacity", opacity),
1060 }
1061 }
1062
1063 pub fn overflow(self, overflow: Overflow) -> Self {
1064 Self {
1065 builder: self.builder.property("overflow", overflow),
1066 }
1067 }
1068
1069 pub fn receives_default(self, receives_default: bool) -> Self {
1070 Self {
1071 builder: self.builder.property("receives-default", receives_default),
1072 }
1073 }
1074
1075 pub fn sensitive(self, sensitive: bool) -> Self {
1076 Self {
1077 builder: self.builder.property("sensitive", sensitive),
1078 }
1079 }
1080
1081 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1082 Self {
1083 builder: self
1084 .builder
1085 .property("tooltip-markup", tooltip_markup.into()),
1086 }
1087 }
1088
1089 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1090 Self {
1091 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1092 }
1093 }
1094
1095 pub fn valign(self, valign: Align) -> Self {
1096 Self {
1097 builder: self.builder.property("valign", valign),
1098 }
1099 }
1100
1101 pub fn vexpand(self, vexpand: bool) -> Self {
1102 Self {
1103 builder: self.builder.property("vexpand", vexpand),
1104 }
1105 }
1106
1107 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1108 Self {
1109 builder: self.builder.property("vexpand-set", vexpand_set),
1110 }
1111 }
1112
1113 pub fn visible(self, visible: bool) -> Self {
1114 Self {
1115 builder: self.builder.property("visible", visible),
1116 }
1117 }
1118
1119 pub fn width_request(self, width_request: i32) -> Self {
1120 Self {
1121 builder: self.builder.property("width-request", width_request),
1122 }
1123 }
1124
1125 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1126 Self {
1127 builder: self.builder.property("accessible-role", accessible_role),
1128 }
1129 }
1130
1131 pub fn editable(self, editable: bool) -> Self {
1132 Self {
1133 builder: self.builder.property("editable", editable),
1134 }
1135 }
1136
1137 pub fn enable_undo(self, enable_undo: bool) -> Self {
1138 Self {
1139 builder: self.builder.property("enable-undo", enable_undo),
1140 }
1141 }
1142
1143 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1144 Self {
1145 builder: self.builder.property("max-width-chars", max_width_chars),
1146 }
1147 }
1148
1149 pub fn text(self, text: impl Into<glib::GString>) -> Self {
1150 Self {
1151 builder: self.builder.property("text", text.into()),
1152 }
1153 }
1154
1155 pub fn width_chars(self, width_chars: i32) -> Self {
1156 Self {
1157 builder: self.builder.property("width-chars", width_chars),
1158 }
1159 }
1160
1161 pub fn xalign(self, xalign: f32) -> Self {
1162 Self {
1163 builder: self.builder.property("xalign", xalign),
1164 }
1165 }
1166
1167 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1170 pub fn build(self) -> Text {
1171 assert_initialized_main_thread!();
1172 self.builder.build()
1173 }
1174}