gtk4/auto/
shortcuts_section.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#![allow(deprecated)]
5
6#[cfg(feature = "v4_14")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
8use crate::ShortcutsGroup;
9use crate::{
10    ffi, Accessible, AccessibleRole, Align, BaselinePosition, Box, Buildable, ConstraintTarget,
11    LayoutManager, Orientable, Orientation, Overflow, Widget,
12};
13use glib::{
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    #[doc(alias = "GtkShortcutsSection")]
22    pub struct ShortcutsSection(Object<ffi::GtkShortcutsSection, ffi::GtkShortcutsSectionClass>) @extends Box, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
23
24    match fn {
25        type_ => || ffi::gtk_shortcuts_section_get_type(),
26    }
27}
28
29impl ShortcutsSection {
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`ShortcutsSection`] objects.
32    ///
33    /// This method returns an instance of [`ShortcutsSectionBuilder`](crate::builders::ShortcutsSectionBuilder) which can be used to create [`ShortcutsSection`] objects.
34    pub fn builder() -> ShortcutsSectionBuilder {
35        ShortcutsSectionBuilder::new()
36    }
37
38    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
39    #[cfg(feature = "v4_14")]
40    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
41    #[allow(deprecated)]
42    #[doc(alias = "gtk_shortcuts_section_add_group")]
43    pub fn add_group(&self, group: &ShortcutsGroup) {
44        unsafe {
45            ffi::gtk_shortcuts_section_add_group(self.to_glib_none().0, group.to_glib_none().0);
46        }
47    }
48
49    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
50    #[doc(alias = "max-height")]
51    pub fn max_height(&self) -> u32 {
52        ObjectExt::property(self, "max-height")
53    }
54
55    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
56    #[doc(alias = "max-height")]
57    pub fn set_max_height(&self, max_height: u32) {
58        ObjectExt::set_property(self, "max-height", max_height)
59    }
60
61    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
62    #[doc(alias = "section-name")]
63    pub fn section_name(&self) -> Option<glib::GString> {
64        ObjectExt::property(self, "section-name")
65    }
66
67    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
68    #[doc(alias = "section-name")]
69    pub fn set_section_name(&self, section_name: Option<&str>) {
70        ObjectExt::set_property(self, "section-name", section_name)
71    }
72
73    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
74    pub fn title(&self) -> Option<glib::GString> {
75        ObjectExt::property(self, "title")
76    }
77
78    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
79    pub fn set_title(&self, title: Option<&str>) {
80        ObjectExt::set_property(self, "title", title)
81    }
82
83    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
84    #[doc(alias = "view-name")]
85    pub fn view_name(&self) -> Option<glib::GString> {
86        ObjectExt::property(self, "view-name")
87    }
88
89    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
90    #[doc(alias = "view-name")]
91    pub fn set_view_name(&self, view_name: Option<&str>) {
92        ObjectExt::set_property(self, "view-name", view_name)
93    }
94
95    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
96    #[doc(alias = "max-height")]
97    pub fn connect_max_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
98        unsafe extern "C" fn notify_max_height_trampoline<F: Fn(&ShortcutsSection) + 'static>(
99            this: *mut ffi::GtkShortcutsSection,
100            _param_spec: glib::ffi::gpointer,
101            f: glib::ffi::gpointer,
102        ) {
103            let f: &F = &*(f as *const F);
104            f(&from_glib_borrow(this))
105        }
106        unsafe {
107            let f: Box_<F> = Box_::new(f);
108            connect_raw(
109                self.as_ptr() as *mut _,
110                c"notify::max-height".as_ptr() as *const _,
111                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
112                    notify_max_height_trampoline::<F> as *const (),
113                )),
114                Box_::into_raw(f),
115            )
116        }
117    }
118
119    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
120    #[doc(alias = "section-name")]
121    pub fn connect_section_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
122        unsafe extern "C" fn notify_section_name_trampoline<F: Fn(&ShortcutsSection) + 'static>(
123            this: *mut ffi::GtkShortcutsSection,
124            _param_spec: glib::ffi::gpointer,
125            f: glib::ffi::gpointer,
126        ) {
127            let f: &F = &*(f as *const F);
128            f(&from_glib_borrow(this))
129        }
130        unsafe {
131            let f: Box_<F> = Box_::new(f);
132            connect_raw(
133                self.as_ptr() as *mut _,
134                c"notify::section-name".as_ptr() as *const _,
135                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
136                    notify_section_name_trampoline::<F> as *const (),
137                )),
138                Box_::into_raw(f),
139            )
140        }
141    }
142
143    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
144    #[doc(alias = "title")]
145    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
146        unsafe extern "C" fn notify_title_trampoline<F: Fn(&ShortcutsSection) + 'static>(
147            this: *mut ffi::GtkShortcutsSection,
148            _param_spec: glib::ffi::gpointer,
149            f: glib::ffi::gpointer,
150        ) {
151            let f: &F = &*(f as *const F);
152            f(&from_glib_borrow(this))
153        }
154        unsafe {
155            let f: Box_<F> = Box_::new(f);
156            connect_raw(
157                self.as_ptr() as *mut _,
158                c"notify::title".as_ptr() as *const _,
159                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
160                    notify_title_trampoline::<F> as *const (),
161                )),
162                Box_::into_raw(f),
163            )
164        }
165    }
166
167    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
168    #[doc(alias = "view-name")]
169    pub fn connect_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
170        unsafe extern "C" fn notify_view_name_trampoline<F: Fn(&ShortcutsSection) + 'static>(
171            this: *mut ffi::GtkShortcutsSection,
172            _param_spec: glib::ffi::gpointer,
173            f: glib::ffi::gpointer,
174        ) {
175            let f: &F = &*(f as *const F);
176            f(&from_glib_borrow(this))
177        }
178        unsafe {
179            let f: Box_<F> = Box_::new(f);
180            connect_raw(
181                self.as_ptr() as *mut _,
182                c"notify::view-name".as_ptr() as *const _,
183                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
184                    notify_view_name_trampoline::<F> as *const (),
185                )),
186                Box_::into_raw(f),
187            )
188        }
189    }
190}
191
192// rustdoc-stripper-ignore-next
193/// A [builder-pattern] type to construct [`ShortcutsSection`] objects.
194///
195/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
196#[must_use = "The builder must be built to be used"]
197pub struct ShortcutsSectionBuilder {
198    builder: glib::object::ObjectBuilder<'static, ShortcutsSection>,
199}
200
201impl ShortcutsSectionBuilder {
202    fn new() -> Self {
203        Self {
204            builder: glib::object::Object::builder(),
205        }
206    }
207
208    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
209    pub fn max_height(self, max_height: u32) -> Self {
210        Self {
211            builder: self.builder.property("max-height", max_height),
212        }
213    }
214
215    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
216    pub fn section_name(self, section_name: impl Into<glib::GString>) -> Self {
217        Self {
218            builder: self.builder.property("section-name", section_name.into()),
219        }
220    }
221
222    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
223    pub fn title(self, title: impl Into<glib::GString>) -> Self {
224        Self {
225            builder: self.builder.property("title", title.into()),
226        }
227    }
228
229    #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
230    pub fn view_name(self, view_name: impl Into<glib::GString>) -> Self {
231        Self {
232            builder: self.builder.property("view-name", view_name.into()),
233        }
234    }
235
236    #[cfg(feature = "v4_12")]
237    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
238    pub fn baseline_child(self, baseline_child: i32) -> Self {
239        Self {
240            builder: self.builder.property("baseline-child", baseline_child),
241        }
242    }
243
244    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
245        Self {
246            builder: self
247                .builder
248                .property("baseline-position", baseline_position),
249        }
250    }
251
252    pub fn homogeneous(self, homogeneous: bool) -> Self {
253        Self {
254            builder: self.builder.property("homogeneous", homogeneous),
255        }
256    }
257
258    pub fn spacing(self, spacing: i32) -> Self {
259        Self {
260            builder: self.builder.property("spacing", spacing),
261        }
262    }
263
264    pub fn can_focus(self, can_focus: bool) -> Self {
265        Self {
266            builder: self.builder.property("can-focus", can_focus),
267        }
268    }
269
270    pub fn can_target(self, can_target: bool) -> Self {
271        Self {
272            builder: self.builder.property("can-target", can_target),
273        }
274    }
275
276    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
277        Self {
278            builder: self.builder.property("css-classes", css_classes.into()),
279        }
280    }
281
282    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
283        Self {
284            builder: self.builder.property("css-name", css_name.into()),
285        }
286    }
287
288    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
289        Self {
290            builder: self.builder.property("cursor", cursor.clone()),
291        }
292    }
293
294    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
295        Self {
296            builder: self.builder.property("focus-on-click", focus_on_click),
297        }
298    }
299
300    pub fn focusable(self, focusable: bool) -> Self {
301        Self {
302            builder: self.builder.property("focusable", focusable),
303        }
304    }
305
306    pub fn halign(self, halign: Align) -> Self {
307        Self {
308            builder: self.builder.property("halign", halign),
309        }
310    }
311
312    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
313        Self {
314            builder: self.builder.property("has-tooltip", has_tooltip),
315        }
316    }
317
318    pub fn height_request(self, height_request: i32) -> Self {
319        Self {
320            builder: self.builder.property("height-request", height_request),
321        }
322    }
323
324    pub fn hexpand(self, hexpand: bool) -> Self {
325        Self {
326            builder: self.builder.property("hexpand", hexpand),
327        }
328    }
329
330    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
331        Self {
332            builder: self.builder.property("hexpand-set", hexpand_set),
333        }
334    }
335
336    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
337        Self {
338            builder: self
339                .builder
340                .property("layout-manager", layout_manager.clone().upcast()),
341        }
342    }
343
344    #[cfg(feature = "v4_18")]
345    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
346    pub fn limit_events(self, limit_events: bool) -> Self {
347        Self {
348            builder: self.builder.property("limit-events", limit_events),
349        }
350    }
351
352    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
353        Self {
354            builder: self.builder.property("margin-bottom", margin_bottom),
355        }
356    }
357
358    pub fn margin_end(self, margin_end: i32) -> Self {
359        Self {
360            builder: self.builder.property("margin-end", margin_end),
361        }
362    }
363
364    pub fn margin_start(self, margin_start: i32) -> Self {
365        Self {
366            builder: self.builder.property("margin-start", margin_start),
367        }
368    }
369
370    pub fn margin_top(self, margin_top: i32) -> Self {
371        Self {
372            builder: self.builder.property("margin-top", margin_top),
373        }
374    }
375
376    pub fn name(self, name: impl Into<glib::GString>) -> Self {
377        Self {
378            builder: self.builder.property("name", name.into()),
379        }
380    }
381
382    pub fn opacity(self, opacity: f64) -> Self {
383        Self {
384            builder: self.builder.property("opacity", opacity),
385        }
386    }
387
388    pub fn overflow(self, overflow: Overflow) -> Self {
389        Self {
390            builder: self.builder.property("overflow", overflow),
391        }
392    }
393
394    pub fn receives_default(self, receives_default: bool) -> Self {
395        Self {
396            builder: self.builder.property("receives-default", receives_default),
397        }
398    }
399
400    pub fn sensitive(self, sensitive: bool) -> Self {
401        Self {
402            builder: self.builder.property("sensitive", sensitive),
403        }
404    }
405
406    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
407        Self {
408            builder: self
409                .builder
410                .property("tooltip-markup", tooltip_markup.into()),
411        }
412    }
413
414    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
415        Self {
416            builder: self.builder.property("tooltip-text", tooltip_text.into()),
417        }
418    }
419
420    pub fn valign(self, valign: Align) -> Self {
421        Self {
422            builder: self.builder.property("valign", valign),
423        }
424    }
425
426    pub fn vexpand(self, vexpand: bool) -> Self {
427        Self {
428            builder: self.builder.property("vexpand", vexpand),
429        }
430    }
431
432    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
433        Self {
434            builder: self.builder.property("vexpand-set", vexpand_set),
435        }
436    }
437
438    pub fn visible(self, visible: bool) -> Self {
439        Self {
440            builder: self.builder.property("visible", visible),
441        }
442    }
443
444    pub fn width_request(self, width_request: i32) -> Self {
445        Self {
446            builder: self.builder.property("width-request", width_request),
447        }
448    }
449
450    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
451        Self {
452            builder: self.builder.property("accessible-role", accessible_role),
453        }
454    }
455
456    pub fn orientation(self, orientation: Orientation) -> Self {
457        Self {
458            builder: self.builder.property("orientation", orientation),
459        }
460    }
461
462    // rustdoc-stripper-ignore-next
463    /// Build the [`ShortcutsSection`].
464    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
465    pub fn build(self) -> ShortcutsSection {
466        assert_initialized_main_thread!();
467        self.builder.build()
468    }
469}