1#[cfg(feature = "v1_2")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
8use crate::TabViewShortcuts;
9use crate::{ffi, TabPage};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "AdwTabView")]
20 pub struct TabView(Object<ffi::AdwTabView, ffi::AdwTabViewClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
21
22 match fn {
23 type_ => || ffi::adw_tab_view_get_type(),
24 }
25}
26
27impl TabView {
28 #[doc(alias = "adw_tab_view_new")]
29 pub fn new() -> TabView {
30 assert_initialized_main_thread!();
31 unsafe { from_glib_none(ffi::adw_tab_view_new()) }
32 }
33
34 pub fn builder() -> TabViewBuilder {
39 TabViewBuilder::new()
40 }
41
42 #[doc(alias = "adw_tab_view_add_page")]
43 pub fn add_page(&self, child: &impl IsA<gtk::Widget>, parent: Option<&TabPage>) -> TabPage {
44 unsafe {
45 from_glib_none(ffi::adw_tab_view_add_page(
46 self.to_glib_none().0,
47 child.as_ref().to_glib_none().0,
48 parent.to_glib_none().0,
49 ))
50 }
51 }
52
53 #[cfg(feature = "v1_2")]
54 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
55 #[doc(alias = "adw_tab_view_add_shortcuts")]
56 pub fn add_shortcuts(&self, shortcuts: TabViewShortcuts) {
57 unsafe {
58 ffi::adw_tab_view_add_shortcuts(self.to_glib_none().0, shortcuts.into_glib());
59 }
60 }
61
62 #[doc(alias = "adw_tab_view_append")]
63 pub fn append(&self, child: &impl IsA<gtk::Widget>) -> TabPage {
64 unsafe {
65 from_glib_none(ffi::adw_tab_view_append(
66 self.to_glib_none().0,
67 child.as_ref().to_glib_none().0,
68 ))
69 }
70 }
71
72 #[doc(alias = "adw_tab_view_append_pinned")]
73 pub fn append_pinned(&self, child: &impl IsA<gtk::Widget>) -> TabPage {
74 unsafe {
75 from_glib_none(ffi::adw_tab_view_append_pinned(
76 self.to_glib_none().0,
77 child.as_ref().to_glib_none().0,
78 ))
79 }
80 }
81
82 #[doc(alias = "adw_tab_view_close_other_pages")]
83 pub fn close_other_pages(&self, page: &TabPage) {
84 unsafe {
85 ffi::adw_tab_view_close_other_pages(self.to_glib_none().0, page.to_glib_none().0);
86 }
87 }
88
89 #[doc(alias = "adw_tab_view_close_page")]
90 pub fn close_page(&self, page: &TabPage) {
91 unsafe {
92 ffi::adw_tab_view_close_page(self.to_glib_none().0, page.to_glib_none().0);
93 }
94 }
95
96 #[doc(alias = "adw_tab_view_close_page_finish")]
97 pub fn close_page_finish(&self, page: &TabPage, confirm: bool) {
98 unsafe {
99 ffi::adw_tab_view_close_page_finish(
100 self.to_glib_none().0,
101 page.to_glib_none().0,
102 confirm.into_glib(),
103 );
104 }
105 }
106
107 #[doc(alias = "adw_tab_view_close_pages_after")]
108 pub fn close_pages_after(&self, page: &TabPage) {
109 unsafe {
110 ffi::adw_tab_view_close_pages_after(self.to_glib_none().0, page.to_glib_none().0);
111 }
112 }
113
114 #[doc(alias = "adw_tab_view_close_pages_before")]
115 pub fn close_pages_before(&self, page: &TabPage) {
116 unsafe {
117 ffi::adw_tab_view_close_pages_before(self.to_glib_none().0, page.to_glib_none().0);
118 }
119 }
120
121 #[doc(alias = "adw_tab_view_get_default_icon")]
122 #[doc(alias = "get_default_icon")]
123 #[doc(alias = "default-icon")]
124 pub fn default_icon(&self) -> gio::Icon {
125 unsafe { from_glib_none(ffi::adw_tab_view_get_default_icon(self.to_glib_none().0)) }
126 }
127
128 #[doc(alias = "adw_tab_view_get_is_transferring_page")]
129 #[doc(alias = "get_is_transferring_page")]
130 #[doc(alias = "is-transferring-page")]
131 pub fn is_transferring_page(&self) -> bool {
132 unsafe {
133 from_glib(ffi::adw_tab_view_get_is_transferring_page(
134 self.to_glib_none().0,
135 ))
136 }
137 }
138
139 #[doc(alias = "adw_tab_view_get_menu_model")]
140 #[doc(alias = "get_menu_model")]
141 #[doc(alias = "menu-model")]
142 pub fn menu_model(&self) -> Option<gio::MenuModel> {
143 unsafe { from_glib_none(ffi::adw_tab_view_get_menu_model(self.to_glib_none().0)) }
144 }
145
146 #[doc(alias = "adw_tab_view_get_n_pages")]
147 #[doc(alias = "get_n_pages")]
148 #[doc(alias = "n-pages")]
149 pub fn n_pages(&self) -> i32 {
150 unsafe { ffi::adw_tab_view_get_n_pages(self.to_glib_none().0) }
151 }
152
153 #[doc(alias = "adw_tab_view_get_n_pinned_pages")]
154 #[doc(alias = "get_n_pinned_pages")]
155 #[doc(alias = "n-pinned-pages")]
156 pub fn n_pinned_pages(&self) -> i32 {
157 unsafe { ffi::adw_tab_view_get_n_pinned_pages(self.to_glib_none().0) }
158 }
159
160 #[doc(alias = "adw_tab_view_get_page")]
161 #[doc(alias = "get_page")]
162 pub fn page(&self, child: &impl IsA<gtk::Widget>) -> TabPage {
163 unsafe {
164 from_glib_none(ffi::adw_tab_view_get_page(
165 self.to_glib_none().0,
166 child.as_ref().to_glib_none().0,
167 ))
168 }
169 }
170
171 #[doc(alias = "adw_tab_view_get_page_position")]
172 #[doc(alias = "get_page_position")]
173 pub fn page_position(&self, page: &TabPage) -> i32 {
174 unsafe { ffi::adw_tab_view_get_page_position(self.to_glib_none().0, page.to_glib_none().0) }
175 }
176
177 #[doc(alias = "adw_tab_view_get_pages")]
178 #[doc(alias = "get_pages")]
179 pub fn pages(&self) -> gtk::SelectionModel {
180 unsafe { from_glib_full(ffi::adw_tab_view_get_pages(self.to_glib_none().0)) }
181 }
182
183 #[doc(alias = "adw_tab_view_get_selected_page")]
184 #[doc(alias = "get_selected_page")]
185 #[doc(alias = "selected-page")]
186 pub fn selected_page(&self) -> Option<TabPage> {
187 unsafe { from_glib_none(ffi::adw_tab_view_get_selected_page(self.to_glib_none().0)) }
188 }
189
190 #[cfg(feature = "v1_2")]
191 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
192 #[doc(alias = "adw_tab_view_get_shortcuts")]
193 #[doc(alias = "get_shortcuts")]
194 pub fn shortcuts(&self) -> TabViewShortcuts {
195 unsafe { from_glib(ffi::adw_tab_view_get_shortcuts(self.to_glib_none().0)) }
196 }
197
198 #[doc(alias = "adw_tab_view_insert")]
199 pub fn insert(&self, child: &impl IsA<gtk::Widget>, position: i32) -> TabPage {
200 unsafe {
201 from_glib_none(ffi::adw_tab_view_insert(
202 self.to_glib_none().0,
203 child.as_ref().to_glib_none().0,
204 position,
205 ))
206 }
207 }
208
209 #[doc(alias = "adw_tab_view_insert_pinned")]
210 pub fn insert_pinned(&self, child: &impl IsA<gtk::Widget>, position: i32) -> TabPage {
211 unsafe {
212 from_glib_none(ffi::adw_tab_view_insert_pinned(
213 self.to_glib_none().0,
214 child.as_ref().to_glib_none().0,
215 position,
216 ))
217 }
218 }
219
220 #[cfg(feature = "v1_3")]
221 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
222 #[doc(alias = "adw_tab_view_invalidate_thumbnails")]
223 pub fn invalidate_thumbnails(&self) {
224 unsafe {
225 ffi::adw_tab_view_invalidate_thumbnails(self.to_glib_none().0);
226 }
227 }
228
229 #[doc(alias = "adw_tab_view_prepend")]
230 pub fn prepend(&self, child: &impl IsA<gtk::Widget>) -> TabPage {
231 unsafe {
232 from_glib_none(ffi::adw_tab_view_prepend(
233 self.to_glib_none().0,
234 child.as_ref().to_glib_none().0,
235 ))
236 }
237 }
238
239 #[doc(alias = "adw_tab_view_prepend_pinned")]
240 pub fn prepend_pinned(&self, child: &impl IsA<gtk::Widget>) -> TabPage {
241 unsafe {
242 from_glib_none(ffi::adw_tab_view_prepend_pinned(
243 self.to_glib_none().0,
244 child.as_ref().to_glib_none().0,
245 ))
246 }
247 }
248
249 #[cfg(feature = "v1_2")]
250 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
251 #[doc(alias = "adw_tab_view_remove_shortcuts")]
252 pub fn remove_shortcuts(&self, shortcuts: TabViewShortcuts) {
253 unsafe {
254 ffi::adw_tab_view_remove_shortcuts(self.to_glib_none().0, shortcuts.into_glib());
255 }
256 }
257
258 #[doc(alias = "adw_tab_view_reorder_backward")]
259 pub fn reorder_backward(&self, page: &TabPage) -> bool {
260 unsafe {
261 from_glib(ffi::adw_tab_view_reorder_backward(
262 self.to_glib_none().0,
263 page.to_glib_none().0,
264 ))
265 }
266 }
267
268 #[doc(alias = "adw_tab_view_reorder_first")]
269 pub fn reorder_first(&self, page: &TabPage) -> bool {
270 unsafe {
271 from_glib(ffi::adw_tab_view_reorder_first(
272 self.to_glib_none().0,
273 page.to_glib_none().0,
274 ))
275 }
276 }
277
278 #[doc(alias = "adw_tab_view_reorder_forward")]
279 pub fn reorder_forward(&self, page: &TabPage) -> bool {
280 unsafe {
281 from_glib(ffi::adw_tab_view_reorder_forward(
282 self.to_glib_none().0,
283 page.to_glib_none().0,
284 ))
285 }
286 }
287
288 #[doc(alias = "adw_tab_view_reorder_last")]
289 pub fn reorder_last(&self, page: &TabPage) -> bool {
290 unsafe {
291 from_glib(ffi::adw_tab_view_reorder_last(
292 self.to_glib_none().0,
293 page.to_glib_none().0,
294 ))
295 }
296 }
297
298 #[doc(alias = "adw_tab_view_reorder_page")]
299 pub fn reorder_page(&self, page: &TabPage, position: i32) -> bool {
300 unsafe {
301 from_glib(ffi::adw_tab_view_reorder_page(
302 self.to_glib_none().0,
303 page.to_glib_none().0,
304 position,
305 ))
306 }
307 }
308
309 #[doc(alias = "adw_tab_view_select_next_page")]
310 pub fn select_next_page(&self) -> bool {
311 unsafe { from_glib(ffi::adw_tab_view_select_next_page(self.to_glib_none().0)) }
312 }
313
314 #[doc(alias = "adw_tab_view_select_previous_page")]
315 pub fn select_previous_page(&self) -> bool {
316 unsafe {
317 from_glib(ffi::adw_tab_view_select_previous_page(
318 self.to_glib_none().0,
319 ))
320 }
321 }
322
323 #[doc(alias = "adw_tab_view_set_default_icon")]
324 #[doc(alias = "default-icon")]
325 pub fn set_default_icon(&self, default_icon: &impl IsA<gio::Icon>) {
326 unsafe {
327 ffi::adw_tab_view_set_default_icon(
328 self.to_glib_none().0,
329 default_icon.as_ref().to_glib_none().0,
330 );
331 }
332 }
333
334 #[doc(alias = "adw_tab_view_set_menu_model")]
335 #[doc(alias = "menu-model")]
336 pub fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
337 unsafe {
338 ffi::adw_tab_view_set_menu_model(
339 self.to_glib_none().0,
340 menu_model.map(|p| p.as_ref()).to_glib_none().0,
341 );
342 }
343 }
344
345 #[doc(alias = "adw_tab_view_set_page_pinned")]
346 pub fn set_page_pinned(&self, page: &TabPage, pinned: bool) {
347 unsafe {
348 ffi::adw_tab_view_set_page_pinned(
349 self.to_glib_none().0,
350 page.to_glib_none().0,
351 pinned.into_glib(),
352 );
353 }
354 }
355
356 #[doc(alias = "adw_tab_view_set_selected_page")]
357 #[doc(alias = "selected-page")]
358 pub fn set_selected_page(&self, selected_page: &TabPage) {
359 unsafe {
360 ffi::adw_tab_view_set_selected_page(
361 self.to_glib_none().0,
362 selected_page.to_glib_none().0,
363 );
364 }
365 }
366
367 #[cfg(feature = "v1_2")]
368 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
369 #[doc(alias = "adw_tab_view_set_shortcuts")]
370 #[doc(alias = "shortcuts")]
371 pub fn set_shortcuts(&self, shortcuts: TabViewShortcuts) {
372 unsafe {
373 ffi::adw_tab_view_set_shortcuts(self.to_glib_none().0, shortcuts.into_glib());
374 }
375 }
376
377 #[doc(alias = "adw_tab_view_transfer_page")]
378 pub fn transfer_page(&self, page: &TabPage, other_view: &TabView, position: i32) {
379 unsafe {
380 ffi::adw_tab_view_transfer_page(
381 self.to_glib_none().0,
382 page.to_glib_none().0,
383 other_view.to_glib_none().0,
384 position,
385 );
386 }
387 }
388
389 #[doc(alias = "close-page")]
390 pub fn connect_close_page<F: Fn(&Self, &TabPage) -> glib::Propagation + 'static>(
391 &self,
392 f: F,
393 ) -> SignalHandlerId {
394 unsafe extern "C" fn close_page_trampoline<
395 F: Fn(&TabView, &TabPage) -> glib::Propagation + 'static,
396 >(
397 this: *mut ffi::AdwTabView,
398 page: *mut ffi::AdwTabPage,
399 f: glib::ffi::gpointer,
400 ) -> glib::ffi::gboolean {
401 let f: &F = &*(f as *const F);
402 f(&from_glib_borrow(this), &from_glib_borrow(page)).into_glib()
403 }
404 unsafe {
405 let f: Box_<F> = Box_::new(f);
406 connect_raw(
407 self.as_ptr() as *mut _,
408 c"close-page".as_ptr() as *const _,
409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
410 close_page_trampoline::<F> as *const (),
411 )),
412 Box_::into_raw(f),
413 )
414 }
415 }
416
417 #[doc(alias = "create-window")]
418 pub fn connect_create_window<F: Fn(&Self) -> Option<TabView> + 'static>(
419 &self,
420 f: F,
421 ) -> SignalHandlerId {
422 unsafe extern "C" fn create_window_trampoline<
423 F: Fn(&TabView) -> Option<TabView> + 'static,
424 >(
425 this: *mut ffi::AdwTabView,
426 f: glib::ffi::gpointer,
427 ) -> *mut ffi::AdwTabView {
428 let f: &F = &*(f as *const F);
429 f(&from_glib_borrow(this)) .to_glib_none()
431 .0
432 }
433 unsafe {
434 let f: Box_<F> = Box_::new(f);
435 connect_raw(
436 self.as_ptr() as *mut _,
437 c"create-window".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 create_window_trampoline::<F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445
446 #[doc(alias = "indicator-activated")]
447 pub fn connect_indicator_activated<F: Fn(&Self, &TabPage) + 'static>(
448 &self,
449 f: F,
450 ) -> SignalHandlerId {
451 unsafe extern "C" fn indicator_activated_trampoline<F: Fn(&TabView, &TabPage) + 'static>(
452 this: *mut ffi::AdwTabView,
453 page: *mut ffi::AdwTabPage,
454 f: glib::ffi::gpointer,
455 ) {
456 let f: &F = &*(f as *const F);
457 f(&from_glib_borrow(this), &from_glib_borrow(page))
458 }
459 unsafe {
460 let f: Box_<F> = Box_::new(f);
461 connect_raw(
462 self.as_ptr() as *mut _,
463 c"indicator-activated".as_ptr() as *const _,
464 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
465 indicator_activated_trampoline::<F> as *const (),
466 )),
467 Box_::into_raw(f),
468 )
469 }
470 }
471
472 #[doc(alias = "page-attached")]
473 pub fn connect_page_attached<F: Fn(&Self, &TabPage, i32) + 'static>(
474 &self,
475 f: F,
476 ) -> SignalHandlerId {
477 unsafe extern "C" fn page_attached_trampoline<F: Fn(&TabView, &TabPage, i32) + 'static>(
478 this: *mut ffi::AdwTabView,
479 page: *mut ffi::AdwTabPage,
480 position: std::ffi::c_int,
481 f: glib::ffi::gpointer,
482 ) {
483 let f: &F = &*(f as *const F);
484 f(&from_glib_borrow(this), &from_glib_borrow(page), position)
485 }
486 unsafe {
487 let f: Box_<F> = Box_::new(f);
488 connect_raw(
489 self.as_ptr() as *mut _,
490 c"page-attached".as_ptr() as *const _,
491 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492 page_attached_trampoline::<F> as *const (),
493 )),
494 Box_::into_raw(f),
495 )
496 }
497 }
498
499 #[doc(alias = "page-detached")]
500 pub fn connect_page_detached<F: Fn(&Self, &TabPage, i32) + 'static>(
501 &self,
502 f: F,
503 ) -> SignalHandlerId {
504 unsafe extern "C" fn page_detached_trampoline<F: Fn(&TabView, &TabPage, i32) + 'static>(
505 this: *mut ffi::AdwTabView,
506 page: *mut ffi::AdwTabPage,
507 position: std::ffi::c_int,
508 f: glib::ffi::gpointer,
509 ) {
510 let f: &F = &*(f as *const F);
511 f(&from_glib_borrow(this), &from_glib_borrow(page), position)
512 }
513 unsafe {
514 let f: Box_<F> = Box_::new(f);
515 connect_raw(
516 self.as_ptr() as *mut _,
517 c"page-detached".as_ptr() as *const _,
518 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
519 page_detached_trampoline::<F> as *const (),
520 )),
521 Box_::into_raw(f),
522 )
523 }
524 }
525
526 #[doc(alias = "page-reordered")]
527 pub fn connect_page_reordered<F: Fn(&Self, &TabPage, i32) + 'static>(
528 &self,
529 f: F,
530 ) -> SignalHandlerId {
531 unsafe extern "C" fn page_reordered_trampoline<F: Fn(&TabView, &TabPage, i32) + 'static>(
532 this: *mut ffi::AdwTabView,
533 page: *mut ffi::AdwTabPage,
534 position: std::ffi::c_int,
535 f: glib::ffi::gpointer,
536 ) {
537 let f: &F = &*(f as *const F);
538 f(&from_glib_borrow(this), &from_glib_borrow(page), position)
539 }
540 unsafe {
541 let f: Box_<F> = Box_::new(f);
542 connect_raw(
543 self.as_ptr() as *mut _,
544 c"page-reordered".as_ptr() as *const _,
545 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
546 page_reordered_trampoline::<F> as *const (),
547 )),
548 Box_::into_raw(f),
549 )
550 }
551 }
552
553 #[doc(alias = "setup-menu")]
554 pub fn connect_setup_menu<F: Fn(&Self, Option<&TabPage>) + 'static>(
555 &self,
556 f: F,
557 ) -> SignalHandlerId {
558 unsafe extern "C" fn setup_menu_trampoline<F: Fn(&TabView, Option<&TabPage>) + 'static>(
559 this: *mut ffi::AdwTabView,
560 page: *mut ffi::AdwTabPage,
561 f: glib::ffi::gpointer,
562 ) {
563 let f: &F = &*(f as *const F);
564 f(
565 &from_glib_borrow(this),
566 Option::<TabPage>::from_glib_borrow(page).as_ref().as_ref(),
567 )
568 }
569 unsafe {
570 let f: Box_<F> = Box_::new(f);
571 connect_raw(
572 self.as_ptr() as *mut _,
573 c"setup-menu".as_ptr() as *const _,
574 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575 setup_menu_trampoline::<F> as *const (),
576 )),
577 Box_::into_raw(f),
578 )
579 }
580 }
581
582 #[doc(alias = "default-icon")]
583 pub fn connect_default_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
584 unsafe extern "C" fn notify_default_icon_trampoline<F: Fn(&TabView) + 'static>(
585 this: *mut ffi::AdwTabView,
586 _param_spec: glib::ffi::gpointer,
587 f: glib::ffi::gpointer,
588 ) {
589 let f: &F = &*(f as *const F);
590 f(&from_glib_borrow(this))
591 }
592 unsafe {
593 let f: Box_<F> = Box_::new(f);
594 connect_raw(
595 self.as_ptr() as *mut _,
596 c"notify::default-icon".as_ptr() as *const _,
597 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
598 notify_default_icon_trampoline::<F> as *const (),
599 )),
600 Box_::into_raw(f),
601 )
602 }
603 }
604
605 #[doc(alias = "is-transferring-page")]
606 pub fn connect_is_transferring_page_notify<F: Fn(&Self) + 'static>(
607 &self,
608 f: F,
609 ) -> SignalHandlerId {
610 unsafe extern "C" fn notify_is_transferring_page_trampoline<F: Fn(&TabView) + 'static>(
611 this: *mut ffi::AdwTabView,
612 _param_spec: glib::ffi::gpointer,
613 f: glib::ffi::gpointer,
614 ) {
615 let f: &F = &*(f as *const F);
616 f(&from_glib_borrow(this))
617 }
618 unsafe {
619 let f: Box_<F> = Box_::new(f);
620 connect_raw(
621 self.as_ptr() as *mut _,
622 c"notify::is-transferring-page".as_ptr() as *const _,
623 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
624 notify_is_transferring_page_trampoline::<F> as *const (),
625 )),
626 Box_::into_raw(f),
627 )
628 }
629 }
630
631 #[doc(alias = "menu-model")]
632 pub fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
633 unsafe extern "C" fn notify_menu_model_trampoline<F: Fn(&TabView) + 'static>(
634 this: *mut ffi::AdwTabView,
635 _param_spec: glib::ffi::gpointer,
636 f: glib::ffi::gpointer,
637 ) {
638 let f: &F = &*(f as *const F);
639 f(&from_glib_borrow(this))
640 }
641 unsafe {
642 let f: Box_<F> = Box_::new(f);
643 connect_raw(
644 self.as_ptr() as *mut _,
645 c"notify::menu-model".as_ptr() as *const _,
646 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
647 notify_menu_model_trampoline::<F> as *const (),
648 )),
649 Box_::into_raw(f),
650 )
651 }
652 }
653
654 #[doc(alias = "n-pages")]
655 pub fn connect_n_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
656 unsafe extern "C" fn notify_n_pages_trampoline<F: Fn(&TabView) + 'static>(
657 this: *mut ffi::AdwTabView,
658 _param_spec: glib::ffi::gpointer,
659 f: glib::ffi::gpointer,
660 ) {
661 let f: &F = &*(f as *const F);
662 f(&from_glib_borrow(this))
663 }
664 unsafe {
665 let f: Box_<F> = Box_::new(f);
666 connect_raw(
667 self.as_ptr() as *mut _,
668 c"notify::n-pages".as_ptr() as *const _,
669 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
670 notify_n_pages_trampoline::<F> as *const (),
671 )),
672 Box_::into_raw(f),
673 )
674 }
675 }
676
677 #[doc(alias = "n-pinned-pages")]
678 pub fn connect_n_pinned_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
679 unsafe extern "C" fn notify_n_pinned_pages_trampoline<F: Fn(&TabView) + 'static>(
680 this: *mut ffi::AdwTabView,
681 _param_spec: glib::ffi::gpointer,
682 f: glib::ffi::gpointer,
683 ) {
684 let f: &F = &*(f as *const F);
685 f(&from_glib_borrow(this))
686 }
687 unsafe {
688 let f: Box_<F> = Box_::new(f);
689 connect_raw(
690 self.as_ptr() as *mut _,
691 c"notify::n-pinned-pages".as_ptr() as *const _,
692 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
693 notify_n_pinned_pages_trampoline::<F> as *const (),
694 )),
695 Box_::into_raw(f),
696 )
697 }
698 }
699
700 #[doc(alias = "pages")]
701 pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
702 unsafe extern "C" fn notify_pages_trampoline<F: Fn(&TabView) + 'static>(
703 this: *mut ffi::AdwTabView,
704 _param_spec: glib::ffi::gpointer,
705 f: glib::ffi::gpointer,
706 ) {
707 let f: &F = &*(f as *const F);
708 f(&from_glib_borrow(this))
709 }
710 unsafe {
711 let f: Box_<F> = Box_::new(f);
712 connect_raw(
713 self.as_ptr() as *mut _,
714 c"notify::pages".as_ptr() as *const _,
715 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
716 notify_pages_trampoline::<F> as *const (),
717 )),
718 Box_::into_raw(f),
719 )
720 }
721 }
722
723 #[doc(alias = "selected-page")]
724 pub fn connect_selected_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
725 unsafe extern "C" fn notify_selected_page_trampoline<F: Fn(&TabView) + 'static>(
726 this: *mut ffi::AdwTabView,
727 _param_spec: glib::ffi::gpointer,
728 f: glib::ffi::gpointer,
729 ) {
730 let f: &F = &*(f as *const F);
731 f(&from_glib_borrow(this))
732 }
733 unsafe {
734 let f: Box_<F> = Box_::new(f);
735 connect_raw(
736 self.as_ptr() as *mut _,
737 c"notify::selected-page".as_ptr() as *const _,
738 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
739 notify_selected_page_trampoline::<F> as *const (),
740 )),
741 Box_::into_raw(f),
742 )
743 }
744 }
745
746 #[cfg(feature = "v1_2")]
747 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
748 #[doc(alias = "shortcuts")]
749 pub fn connect_shortcuts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
750 unsafe extern "C" fn notify_shortcuts_trampoline<F: Fn(&TabView) + 'static>(
751 this: *mut ffi::AdwTabView,
752 _param_spec: glib::ffi::gpointer,
753 f: glib::ffi::gpointer,
754 ) {
755 let f: &F = &*(f as *const F);
756 f(&from_glib_borrow(this))
757 }
758 unsafe {
759 let f: Box_<F> = Box_::new(f);
760 connect_raw(
761 self.as_ptr() as *mut _,
762 c"notify::shortcuts".as_ptr() as *const _,
763 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
764 notify_shortcuts_trampoline::<F> as *const (),
765 )),
766 Box_::into_raw(f),
767 )
768 }
769 }
770}
771
772impl Default for TabView {
773 fn default() -> Self {
774 Self::new()
775 }
776}
777
778#[must_use = "The builder must be built to be used"]
783pub struct TabViewBuilder {
784 builder: glib::object::ObjectBuilder<'static, TabView>,
785}
786
787impl TabViewBuilder {
788 fn new() -> Self {
789 Self {
790 builder: glib::object::Object::builder(),
791 }
792 }
793
794 pub fn default_icon(self, default_icon: &impl IsA<gio::Icon>) -> Self {
795 Self {
796 builder: self
797 .builder
798 .property("default-icon", default_icon.clone().upcast()),
799 }
800 }
801
802 pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
803 Self {
804 builder: self
805 .builder
806 .property("menu-model", menu_model.clone().upcast()),
807 }
808 }
809
810 pub fn selected_page(self, selected_page: &TabPage) -> Self {
811 Self {
812 builder: self
813 .builder
814 .property("selected-page", selected_page.clone()),
815 }
816 }
817
818 #[cfg(feature = "v1_2")]
819 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
820 pub fn shortcuts(self, shortcuts: TabViewShortcuts) -> Self {
821 Self {
822 builder: self.builder.property("shortcuts", shortcuts),
823 }
824 }
825
826 pub fn can_focus(self, can_focus: bool) -> Self {
827 Self {
828 builder: self.builder.property("can-focus", can_focus),
829 }
830 }
831
832 pub fn can_target(self, can_target: bool) -> Self {
833 Self {
834 builder: self.builder.property("can-target", can_target),
835 }
836 }
837
838 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
839 Self {
840 builder: self.builder.property("css-classes", css_classes.into()),
841 }
842 }
843
844 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
845 Self {
846 builder: self.builder.property("css-name", css_name.into()),
847 }
848 }
849
850 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
851 Self {
852 builder: self.builder.property("cursor", cursor.clone()),
853 }
854 }
855
856 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
857 Self {
858 builder: self.builder.property("focus-on-click", focus_on_click),
859 }
860 }
861
862 pub fn focusable(self, focusable: bool) -> Self {
863 Self {
864 builder: self.builder.property("focusable", focusable),
865 }
866 }
867
868 pub fn halign(self, halign: gtk::Align) -> Self {
869 Self {
870 builder: self.builder.property("halign", halign),
871 }
872 }
873
874 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
875 Self {
876 builder: self.builder.property("has-tooltip", has_tooltip),
877 }
878 }
879
880 pub fn height_request(self, height_request: i32) -> Self {
881 Self {
882 builder: self.builder.property("height-request", height_request),
883 }
884 }
885
886 pub fn hexpand(self, hexpand: bool) -> Self {
887 Self {
888 builder: self.builder.property("hexpand", hexpand),
889 }
890 }
891
892 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
893 Self {
894 builder: self.builder.property("hexpand-set", hexpand_set),
895 }
896 }
897
898 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
899 Self {
900 builder: self
901 .builder
902 .property("layout-manager", layout_manager.clone().upcast()),
903 }
904 }
905
906 #[cfg(feature = "gtk_v4_18")]
907 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
908 pub fn limit_events(self, limit_events: bool) -> Self {
909 Self {
910 builder: self.builder.property("limit-events", limit_events),
911 }
912 }
913
914 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
915 Self {
916 builder: self.builder.property("margin-bottom", margin_bottom),
917 }
918 }
919
920 pub fn margin_end(self, margin_end: i32) -> Self {
921 Self {
922 builder: self.builder.property("margin-end", margin_end),
923 }
924 }
925
926 pub fn margin_start(self, margin_start: i32) -> Self {
927 Self {
928 builder: self.builder.property("margin-start", margin_start),
929 }
930 }
931
932 pub fn margin_top(self, margin_top: i32) -> Self {
933 Self {
934 builder: self.builder.property("margin-top", margin_top),
935 }
936 }
937
938 pub fn name(self, name: impl Into<glib::GString>) -> Self {
939 Self {
940 builder: self.builder.property("name", name.into()),
941 }
942 }
943
944 pub fn opacity(self, opacity: f64) -> Self {
945 Self {
946 builder: self.builder.property("opacity", opacity),
947 }
948 }
949
950 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
951 Self {
952 builder: self.builder.property("overflow", overflow),
953 }
954 }
955
956 pub fn receives_default(self, receives_default: bool) -> Self {
957 Self {
958 builder: self.builder.property("receives-default", receives_default),
959 }
960 }
961
962 pub fn sensitive(self, sensitive: bool) -> Self {
963 Self {
964 builder: self.builder.property("sensitive", sensitive),
965 }
966 }
967
968 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
969 Self {
970 builder: self
971 .builder
972 .property("tooltip-markup", tooltip_markup.into()),
973 }
974 }
975
976 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
977 Self {
978 builder: self.builder.property("tooltip-text", tooltip_text.into()),
979 }
980 }
981
982 pub fn valign(self, valign: gtk::Align) -> Self {
983 Self {
984 builder: self.builder.property("valign", valign),
985 }
986 }
987
988 pub fn vexpand(self, vexpand: bool) -> Self {
989 Self {
990 builder: self.builder.property("vexpand", vexpand),
991 }
992 }
993
994 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
995 Self {
996 builder: self.builder.property("vexpand-set", vexpand_set),
997 }
998 }
999
1000 pub fn visible(self, visible: bool) -> Self {
1001 Self {
1002 builder: self.builder.property("visible", visible),
1003 }
1004 }
1005
1006 pub fn width_request(self, width_request: i32) -> Self {
1007 Self {
1008 builder: self.builder.property("width-request", width_request),
1009 }
1010 }
1011
1012 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1013 Self {
1014 builder: self.builder.property("accessible-role", accessible_role),
1015 }
1016 }
1017
1018 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1021 pub fn build(self) -> TabView {
1022 assert_initialized_main_thread!();
1023 self.builder.build()
1024 }
1025}