[go: up one dir, main page]

gtk4/auto/
action_bar.rs

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