libpanel/auto/
document_workspace.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, Dock, Grid, Statusbar, Workspace};
7#[cfg(feature = "v1_4")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
9use crate::{Frame, Position, Widget};
10#[cfg(feature = "v1_4")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
12use glib::object::ObjectType as _;
13use glib::{
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    #[doc(alias = "PanelDocumentWorkspace")]
22    pub struct DocumentWorkspace(Object<ffi::PanelDocumentWorkspace, ffi::PanelDocumentWorkspaceClass>) @extends Workspace, adw::ApplicationWindow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager, gio::ActionGroup;
23
24    match fn {
25        type_ => || ffi::panel_document_workspace_get_type(),
26    }
27}
28
29impl DocumentWorkspace {
30    pub const NONE: Option<&'static DocumentWorkspace> = None;
31
32    #[cfg(feature = "v1_4")]
33    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
34    #[doc(alias = "panel_document_workspace_new")]
35    pub fn new() -> DocumentWorkspace {
36        assert_initialized_main_thread!();
37        unsafe { from_glib_full(ffi::panel_document_workspace_new()) }
38    }
39
40    // rustdoc-stripper-ignore-next
41    /// Creates a new builder-pattern struct instance to construct [`DocumentWorkspace`] objects.
42    ///
43    /// This method returns an instance of [`DocumentWorkspaceBuilder`](crate::builders::DocumentWorkspaceBuilder) which can be used to create [`DocumentWorkspace`] objects.
44    pub fn builder() -> DocumentWorkspaceBuilder {
45        DocumentWorkspaceBuilder::new()
46    }
47}
48
49#[cfg(feature = "v1_4")]
50#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
51impl Default for DocumentWorkspace {
52    fn default() -> Self {
53        Self::new()
54    }
55}
56
57// rustdoc-stripper-ignore-next
58/// A [builder-pattern] type to construct [`DocumentWorkspace`] objects.
59///
60/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
61#[must_use = "The builder must be built to be used"]
62pub struct DocumentWorkspaceBuilder {
63    builder: glib::object::ObjectBuilder<'static, DocumentWorkspace>,
64}
65
66impl DocumentWorkspaceBuilder {
67    fn new() -> Self {
68        Self {
69            builder: glib::object::Object::builder(),
70        }
71    }
72
73    #[cfg(feature = "v1_4")]
74    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
75    pub fn id(self, id: impl Into<glib::GString>) -> Self {
76        Self {
77            builder: self.builder.property("id", id.into()),
78        }
79    }
80
81    pub fn content(self, content: &impl IsA<gtk::Widget>) -> Self {
82        Self {
83            builder: self.builder.property("content", content.clone().upcast()),
84        }
85    }
86
87    pub fn can_focus(self, can_focus: bool) -> Self {
88        Self {
89            builder: self.builder.property("can-focus", can_focus),
90        }
91    }
92
93    pub fn can_target(self, can_target: bool) -> Self {
94        Self {
95            builder: self.builder.property("can-target", can_target),
96        }
97    }
98
99    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
100        Self {
101            builder: self.builder.property("css-classes", css_classes.into()),
102        }
103    }
104
105    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
106        Self {
107            builder: self.builder.property("css-name", css_name.into()),
108        }
109    }
110
111    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
112        Self {
113            builder: self.builder.property("cursor", cursor.clone()),
114        }
115    }
116
117    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
118        Self {
119            builder: self.builder.property("focus-on-click", focus_on_click),
120        }
121    }
122
123    pub fn focusable(self, focusable: bool) -> Self {
124        Self {
125            builder: self.builder.property("focusable", focusable),
126        }
127    }
128
129    pub fn halign(self, halign: gtk::Align) -> Self {
130        Self {
131            builder: self.builder.property("halign", halign),
132        }
133    }
134
135    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
136        Self {
137            builder: self.builder.property("has-tooltip", has_tooltip),
138        }
139    }
140
141    pub fn height_request(self, height_request: i32) -> Self {
142        Self {
143            builder: self.builder.property("height-request", height_request),
144        }
145    }
146
147    pub fn hexpand(self, hexpand: bool) -> Self {
148        Self {
149            builder: self.builder.property("hexpand", hexpand),
150        }
151    }
152
153    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
154        Self {
155            builder: self.builder.property("hexpand-set", hexpand_set),
156        }
157    }
158
159    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
160        Self {
161            builder: self
162                .builder
163                .property("layout-manager", layout_manager.clone().upcast()),
164        }
165    }
166
167    #[cfg(feature = "gtk_v4_18")]
168    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
169    pub fn limit_events(self, limit_events: bool) -> Self {
170        Self {
171            builder: self.builder.property("limit-events", limit_events),
172        }
173    }
174
175    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
176        Self {
177            builder: self.builder.property("margin-bottom", margin_bottom),
178        }
179    }
180
181    pub fn margin_end(self, margin_end: i32) -> Self {
182        Self {
183            builder: self.builder.property("margin-end", margin_end),
184        }
185    }
186
187    pub fn margin_start(self, margin_start: i32) -> Self {
188        Self {
189            builder: self.builder.property("margin-start", margin_start),
190        }
191    }
192
193    pub fn margin_top(self, margin_top: i32) -> Self {
194        Self {
195            builder: self.builder.property("margin-top", margin_top),
196        }
197    }
198
199    pub fn name(self, name: impl Into<glib::GString>) -> Self {
200        Self {
201            builder: self.builder.property("name", name.into()),
202        }
203    }
204
205    pub fn opacity(self, opacity: f64) -> Self {
206        Self {
207            builder: self.builder.property("opacity", opacity),
208        }
209    }
210
211    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
212        Self {
213            builder: self.builder.property("overflow", overflow),
214        }
215    }
216
217    pub fn receives_default(self, receives_default: bool) -> Self {
218        Self {
219            builder: self.builder.property("receives-default", receives_default),
220        }
221    }
222
223    pub fn sensitive(self, sensitive: bool) -> Self {
224        Self {
225            builder: self.builder.property("sensitive", sensitive),
226        }
227    }
228
229    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
230        Self {
231            builder: self
232                .builder
233                .property("tooltip-markup", tooltip_markup.into()),
234        }
235    }
236
237    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
238        Self {
239            builder: self.builder.property("tooltip-text", tooltip_text.into()),
240        }
241    }
242
243    pub fn valign(self, valign: gtk::Align) -> Self {
244        Self {
245            builder: self.builder.property("valign", valign),
246        }
247    }
248
249    pub fn vexpand(self, vexpand: bool) -> Self {
250        Self {
251            builder: self.builder.property("vexpand", vexpand),
252        }
253    }
254
255    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
256        Self {
257            builder: self.builder.property("vexpand-set", vexpand_set),
258        }
259    }
260
261    pub fn visible(self, visible: bool) -> Self {
262        Self {
263            builder: self.builder.property("visible", visible),
264        }
265    }
266
267    pub fn width_request(self, width_request: i32) -> Self {
268        Self {
269            builder: self.builder.property("width-request", width_request),
270        }
271    }
272
273    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
274        Self {
275            builder: self.builder.property("accessible-role", accessible_role),
276        }
277    }
278
279    // rustdoc-stripper-ignore-next
280    /// Build the [`DocumentWorkspace`].
281    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
282    pub fn build(self) -> DocumentWorkspace {
283        assert_initialized_main_thread!();
284        self.builder.build()
285    }
286}
287
288pub trait DocumentWorkspaceExt: IsA<DocumentWorkspace> + 'static {
289    #[cfg(feature = "v1_4")]
290    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
291    #[doc(alias = "panel_document_workspace_add_widget")]
292    fn add_widget(&self, widget: &impl IsA<Widget>, position: Option<&Position>) -> bool {
293        unsafe {
294            from_glib(ffi::panel_document_workspace_add_widget(
295                self.as_ref().to_glib_none().0,
296                widget.as_ref().to_glib_none().0,
297                position.to_glib_none().0,
298            ))
299        }
300    }
301
302    #[cfg(feature = "v1_4")]
303    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
304    #[doc(alias = "panel_document_workspace_get_dock")]
305    #[doc(alias = "get_dock")]
306    fn dock(&self) -> Dock {
307        unsafe {
308            from_glib_none(ffi::panel_document_workspace_get_dock(
309                self.as_ref().to_glib_none().0,
310            ))
311        }
312    }
313
314    #[cfg(feature = "v1_4")]
315    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
316    #[doc(alias = "panel_document_workspace_get_grid")]
317    #[doc(alias = "get_grid")]
318    fn grid(&self) -> Grid {
319        unsafe {
320            from_glib_none(ffi::panel_document_workspace_get_grid(
321                self.as_ref().to_glib_none().0,
322            ))
323        }
324    }
325
326    #[cfg(feature = "v1_4")]
327    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
328    #[doc(alias = "panel_document_workspace_get_statusbar")]
329    #[doc(alias = "get_statusbar")]
330    fn statusbar(&self) -> Option<Statusbar> {
331        unsafe {
332            from_glib_none(ffi::panel_document_workspace_get_statusbar(
333                self.as_ref().to_glib_none().0,
334            ))
335        }
336    }
337
338    #[cfg(feature = "v1_4")]
339    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
340    #[doc(alias = "panel_document_workspace_get_titlebar")]
341    #[doc(alias = "get_titlebar")]
342    fn titlebar(&self) -> Option<gtk::Widget> {
343        unsafe {
344            from_glib_none(ffi::panel_document_workspace_get_titlebar(
345                self.as_ref().to_glib_none().0,
346            ))
347        }
348    }
349
350    #[doc(alias = "panel_document_workspace_set_titlebar")]
351    fn set_titlebar(&self, titlebar: &impl IsA<gtk::Widget>) {
352        unsafe {
353            ffi::panel_document_workspace_set_titlebar(
354                self.as_ref().to_glib_none().0,
355                titlebar.as_ref().to_glib_none().0,
356            );
357        }
358    }
359
360    #[cfg(not(feature = "v1_4"))]
361    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_4"))))]
362    fn dock(&self) -> Option<Dock> {
363        ObjectExt::property(self.as_ref(), "dock")
364    }
365
366    #[cfg(not(feature = "v1_4"))]
367    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_4"))))]
368    fn grid(&self) -> Option<Grid> {
369        ObjectExt::property(self.as_ref(), "grid")
370    }
371
372    #[cfg(not(feature = "v1_4"))]
373    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_4"))))]
374    fn statusbar(&self) -> Option<Statusbar> {
375        ObjectExt::property(self.as_ref(), "statusbar")
376    }
377
378    #[cfg(feature = "v1_4")]
379    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
380    #[doc(alias = "add-widget")]
381    fn connect_add_widget<F: Fn(&Self, &Widget, &Position) -> bool + 'static>(
382        &self,
383        f: F,
384    ) -> SignalHandlerId {
385        unsafe extern "C" fn add_widget_trampoline<
386            P: IsA<DocumentWorkspace>,
387            F: Fn(&P, &Widget, &Position) -> bool + 'static,
388        >(
389            this: *mut ffi::PanelDocumentWorkspace,
390            widget: *mut ffi::PanelWidget,
391            position: *mut ffi::PanelPosition,
392            f: glib::ffi::gpointer,
393        ) -> glib::ffi::gboolean {
394            let f: &F = &*(f as *const F);
395            f(
396                DocumentWorkspace::from_glib_borrow(this).unsafe_cast_ref(),
397                &from_glib_borrow(widget),
398                &from_glib_borrow(position),
399            )
400            .into_glib()
401        }
402        unsafe {
403            let f: Box_<F> = Box_::new(f);
404            connect_raw(
405                self.as_ptr() as *mut _,
406                c"add-widget".as_ptr() as *const _,
407                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
408                    add_widget_trampoline::<Self, F> as *const (),
409                )),
410                Box_::into_raw(f),
411            )
412        }
413    }
414
415    #[cfg(feature = "v1_4")]
416    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
417    #[doc(alias = "create-frame")]
418    fn connect_create_frame<F: Fn(&Self, &Position) -> Frame + 'static>(
419        &self,
420        f: F,
421    ) -> SignalHandlerId {
422        unsafe extern "C" fn create_frame_trampoline<
423            P: IsA<DocumentWorkspace>,
424            F: Fn(&P, &Position) -> Frame + 'static,
425        >(
426            this: *mut ffi::PanelDocumentWorkspace,
427            position: *mut ffi::PanelPosition,
428            f: glib::ffi::gpointer,
429        ) -> *mut ffi::PanelFrame {
430            let f: &F = &*(f as *const F);
431            f(
432                DocumentWorkspace::from_glib_borrow(this).unsafe_cast_ref(),
433                &from_glib_borrow(position),
434            )
435            .to_glib_full()
436        }
437        unsafe {
438            let f: Box_<F> = Box_::new(f);
439            connect_raw(
440                self.as_ptr() as *mut _,
441                c"create-frame".as_ptr() as *const _,
442                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
443                    create_frame_trampoline::<Self, F> as *const (),
444                )),
445                Box_::into_raw(f),
446            )
447        }
448    }
449
450    #[doc(alias = "dock")]
451    fn connect_dock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
452        unsafe extern "C" fn notify_dock_trampoline<
453            P: IsA<DocumentWorkspace>,
454            F: Fn(&P) + 'static,
455        >(
456            this: *mut ffi::PanelDocumentWorkspace,
457            _param_spec: glib::ffi::gpointer,
458            f: glib::ffi::gpointer,
459        ) {
460            let f: &F = &*(f as *const F);
461            f(DocumentWorkspace::from_glib_borrow(this).unsafe_cast_ref())
462        }
463        unsafe {
464            let f: Box_<F> = Box_::new(f);
465            connect_raw(
466                self.as_ptr() as *mut _,
467                c"notify::dock".as_ptr() as *const _,
468                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
469                    notify_dock_trampoline::<Self, F> as *const (),
470                )),
471                Box_::into_raw(f),
472            )
473        }
474    }
475
476    #[doc(alias = "grid")]
477    fn connect_grid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
478        unsafe extern "C" fn notify_grid_trampoline<
479            P: IsA<DocumentWorkspace>,
480            F: Fn(&P) + 'static,
481        >(
482            this: *mut ffi::PanelDocumentWorkspace,
483            _param_spec: glib::ffi::gpointer,
484            f: glib::ffi::gpointer,
485        ) {
486            let f: &F = &*(f as *const F);
487            f(DocumentWorkspace::from_glib_borrow(this).unsafe_cast_ref())
488        }
489        unsafe {
490            let f: Box_<F> = Box_::new(f);
491            connect_raw(
492                self.as_ptr() as *mut _,
493                c"notify::grid".as_ptr() as *const _,
494                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
495                    notify_grid_trampoline::<Self, F> as *const (),
496                )),
497                Box_::into_raw(f),
498            )
499        }
500    }
501
502    #[doc(alias = "statusbar")]
503    fn connect_statusbar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
504        unsafe extern "C" fn notify_statusbar_trampoline<
505            P: IsA<DocumentWorkspace>,
506            F: Fn(&P) + 'static,
507        >(
508            this: *mut ffi::PanelDocumentWorkspace,
509            _param_spec: glib::ffi::gpointer,
510            f: glib::ffi::gpointer,
511        ) {
512            let f: &F = &*(f as *const F);
513            f(DocumentWorkspace::from_glib_borrow(this).unsafe_cast_ref())
514        }
515        unsafe {
516            let f: Box_<F> = Box_::new(f);
517            connect_raw(
518                self.as_ptr() as *mut _,
519                c"notify::statusbar".as_ptr() as *const _,
520                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
521                    notify_statusbar_trampoline::<Self, F> as *const (),
522                )),
523                Box_::into_raw(f),
524            )
525        }
526    }
527}
528
529impl<O: IsA<DocumentWorkspace>> DocumentWorkspaceExt for O {}