libpanel/auto/
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;
7#[cfg(feature = "v1_4")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
9use crate::{Inhibitor, Workbench};
10#[cfg(feature = "v1_4")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
12use glib::signal::{connect_raw, SignalHandlerId};
13use glib::{prelude::*, translate::*};
14#[cfg(feature = "v1_4")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    #[doc(alias = "PanelWorkspace")]
20    pub struct Workspace(Object<ffi::PanelWorkspace, ffi::PanelWorkspaceClass>) @extends adw::ApplicationWindow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager, gio::ActionGroup;
21
22    match fn {
23        type_ => || ffi::panel_workspace_get_type(),
24    }
25}
26
27impl Workspace {
28    pub const NONE: Option<&'static Workspace> = None;
29
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`Workspace`] objects.
32    ///
33    /// This method returns an instance of [`WorkspaceBuilder`](crate::builders::WorkspaceBuilder) which can be used to create [`Workspace`] objects.
34    pub fn builder() -> WorkspaceBuilder {
35        WorkspaceBuilder::new()
36    }
37
38    #[cfg(feature = "v1_4")]
39    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
40    #[doc(alias = "panel_workspace_find_from_widget")]
41    pub fn find_from_widget(widget: &impl IsA<gtk::Widget>) -> Option<Workspace> {
42        assert_initialized_main_thread!();
43        unsafe {
44            from_glib_none(ffi::panel_workspace_find_from_widget(
45                widget.as_ref().to_glib_none().0,
46            ))
47        }
48    }
49}
50
51// rustdoc-stripper-ignore-next
52/// A [builder-pattern] type to construct [`Workspace`] objects.
53///
54/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
55#[must_use = "The builder must be built to be used"]
56pub struct WorkspaceBuilder {
57    builder: glib::object::ObjectBuilder<'static, Workspace>,
58}
59
60impl WorkspaceBuilder {
61    fn new() -> Self {
62        Self {
63            builder: glib::object::Object::builder(),
64        }
65    }
66
67    #[cfg(feature = "v1_4")]
68    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
69    pub fn id(self, id: impl Into<glib::GString>) -> Self {
70        Self {
71            builder: self.builder.property("id", id.into()),
72        }
73    }
74
75    pub fn content(self, content: &impl IsA<gtk::Widget>) -> Self {
76        Self {
77            builder: self.builder.property("content", content.clone().upcast()),
78        }
79    }
80
81    pub fn can_focus(self, can_focus: bool) -> Self {
82        Self {
83            builder: self.builder.property("can-focus", can_focus),
84        }
85    }
86
87    pub fn can_target(self, can_target: bool) -> Self {
88        Self {
89            builder: self.builder.property("can-target", can_target),
90        }
91    }
92
93    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
94        Self {
95            builder: self.builder.property("css-classes", css_classes.into()),
96        }
97    }
98
99    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
100        Self {
101            builder: self.builder.property("css-name", css_name.into()),
102        }
103    }
104
105    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
106        Self {
107            builder: self.builder.property("cursor", cursor.clone()),
108        }
109    }
110
111    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
112        Self {
113            builder: self.builder.property("focus-on-click", focus_on_click),
114        }
115    }
116
117    pub fn focusable(self, focusable: bool) -> Self {
118        Self {
119            builder: self.builder.property("focusable", focusable),
120        }
121    }
122
123    pub fn halign(self, halign: gtk::Align) -> Self {
124        Self {
125            builder: self.builder.property("halign", halign),
126        }
127    }
128
129    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
130        Self {
131            builder: self.builder.property("has-tooltip", has_tooltip),
132        }
133    }
134
135    pub fn height_request(self, height_request: i32) -> Self {
136        Self {
137            builder: self.builder.property("height-request", height_request),
138        }
139    }
140
141    pub fn hexpand(self, hexpand: bool) -> Self {
142        Self {
143            builder: self.builder.property("hexpand", hexpand),
144        }
145    }
146
147    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
148        Self {
149            builder: self.builder.property("hexpand-set", hexpand_set),
150        }
151    }
152
153    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
154        Self {
155            builder: self
156                .builder
157                .property("layout-manager", layout_manager.clone().upcast()),
158        }
159    }
160
161    #[cfg(feature = "gtk_v4_18")]
162    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
163    pub fn limit_events(self, limit_events: bool) -> Self {
164        Self {
165            builder: self.builder.property("limit-events", limit_events),
166        }
167    }
168
169    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
170        Self {
171            builder: self.builder.property("margin-bottom", margin_bottom),
172        }
173    }
174
175    pub fn margin_end(self, margin_end: i32) -> Self {
176        Self {
177            builder: self.builder.property("margin-end", margin_end),
178        }
179    }
180
181    pub fn margin_start(self, margin_start: i32) -> Self {
182        Self {
183            builder: self.builder.property("margin-start", margin_start),
184        }
185    }
186
187    pub fn margin_top(self, margin_top: i32) -> Self {
188        Self {
189            builder: self.builder.property("margin-top", margin_top),
190        }
191    }
192
193    pub fn name(self, name: impl Into<glib::GString>) -> Self {
194        Self {
195            builder: self.builder.property("name", name.into()),
196        }
197    }
198
199    pub fn opacity(self, opacity: f64) -> Self {
200        Self {
201            builder: self.builder.property("opacity", opacity),
202        }
203    }
204
205    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
206        Self {
207            builder: self.builder.property("overflow", overflow),
208        }
209    }
210
211    pub fn receives_default(self, receives_default: bool) -> Self {
212        Self {
213            builder: self.builder.property("receives-default", receives_default),
214        }
215    }
216
217    pub fn sensitive(self, sensitive: bool) -> Self {
218        Self {
219            builder: self.builder.property("sensitive", sensitive),
220        }
221    }
222
223    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
224        Self {
225            builder: self
226                .builder
227                .property("tooltip-markup", tooltip_markup.into()),
228        }
229    }
230
231    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
232        Self {
233            builder: self.builder.property("tooltip-text", tooltip_text.into()),
234        }
235    }
236
237    pub fn valign(self, valign: gtk::Align) -> Self {
238        Self {
239            builder: self.builder.property("valign", valign),
240        }
241    }
242
243    pub fn vexpand(self, vexpand: bool) -> Self {
244        Self {
245            builder: self.builder.property("vexpand", vexpand),
246        }
247    }
248
249    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
250        Self {
251            builder: self.builder.property("vexpand-set", vexpand_set),
252        }
253    }
254
255    pub fn visible(self, visible: bool) -> Self {
256        Self {
257            builder: self.builder.property("visible", visible),
258        }
259    }
260
261    pub fn width_request(self, width_request: i32) -> Self {
262        Self {
263            builder: self.builder.property("width-request", width_request),
264        }
265    }
266
267    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
268        Self {
269            builder: self.builder.property("accessible-role", accessible_role),
270        }
271    }
272
273    // rustdoc-stripper-ignore-next
274    /// Build the [`Workspace`].
275    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
276    pub fn build(self) -> Workspace {
277        assert_initialized_main_thread!();
278        self.builder.build()
279    }
280}
281
282pub trait WorkspaceExt: IsA<Workspace> + 'static {
283    #[doc(alias = "panel_workspace_action_set_enabled")]
284    fn action_set_enabled(&self, action_name: &str, enabled: bool) {
285        unsafe {
286            ffi::panel_workspace_action_set_enabled(
287                self.as_ref().to_glib_none().0,
288                action_name.to_glib_none().0,
289                enabled.into_glib(),
290            );
291        }
292    }
293
294    #[doc(alias = "panel_workspace_get_id")]
295    #[doc(alias = "get_id")]
296    fn id(&self) -> glib::GString {
297        unsafe { from_glib_none(ffi::panel_workspace_get_id(self.as_ref().to_glib_none().0)) }
298    }
299
300    #[cfg(feature = "v1_4")]
301    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
302    #[doc(alias = "panel_workspace_get_workbench")]
303    #[doc(alias = "get_workbench")]
304    fn workbench(&self) -> Option<Workbench> {
305        unsafe {
306            from_glib_none(ffi::panel_workspace_get_workbench(
307                self.as_ref().to_glib_none().0,
308            ))
309        }
310    }
311
312    #[cfg(feature = "v1_4")]
313    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
314    #[doc(alias = "panel_workspace_inhibit")]
315    fn inhibit(&self, flags: gtk::ApplicationInhibitFlags, reason: &str) -> Option<Inhibitor> {
316        unsafe {
317            from_glib_full(ffi::panel_workspace_inhibit(
318                self.as_ref().to_glib_none().0,
319                flags.into_glib(),
320                reason.to_glib_none().0,
321            ))
322        }
323    }
324
325    #[doc(alias = "panel_workspace_set_id")]
326    #[doc(alias = "id")]
327    fn set_id(&self, id: &str) {
328        unsafe {
329            ffi::panel_workspace_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
330        }
331    }
332
333    #[cfg(feature = "v1_4")]
334    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
335    #[doc(alias = "id")]
336    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
337        unsafe extern "C" fn notify_id_trampoline<P: IsA<Workspace>, F: Fn(&P) + 'static>(
338            this: *mut ffi::PanelWorkspace,
339            _param_spec: glib::ffi::gpointer,
340            f: glib::ffi::gpointer,
341        ) {
342            let f: &F = &*(f as *const F);
343            f(Workspace::from_glib_borrow(this).unsafe_cast_ref())
344        }
345        unsafe {
346            let f: Box_<F> = Box_::new(f);
347            connect_raw(
348                self.as_ptr() as *mut _,
349                c"notify::id".as_ptr() as *const _,
350                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
351                    notify_id_trampoline::<Self, F> as *const (),
352                )),
353                Box_::into_raw(f),
354            )
355        }
356    }
357}
358
359impl<O: IsA<Workspace>> WorkspaceExt for O {}