libpanel/auto/
paned.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;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// A [`Paned`][crate::Paned] is the concrete widget for a panel area.
11    ///
12    /// # Implements
13    ///
14    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::OrientableExt`]
15    #[doc(alias = "PanelPaned")]
16    pub struct Paned(Object<ffi::PanelPaned, ffi::PanelPanedClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
17
18    match fn {
19        type_ => || ffi::panel_paned_get_type(),
20    }
21}
22
23impl Paned {
24    /// Create a new [`Paned`][crate::Paned].
25    ///
26    /// # Returns
27    ///
28    /// a newly created [`Paned`][crate::Paned]
29    #[doc(alias = "panel_paned_new")]
30    pub fn new() -> Paned {
31        assert_initialized_main_thread!();
32        unsafe { gtk::Widget::from_glib_none(ffi::panel_paned_new()).unsafe_cast() }
33    }
34
35    // rustdoc-stripper-ignore-next
36    /// Creates a new builder-pattern struct instance to construct [`Paned`] objects.
37    ///
38    /// This method returns an instance of [`PanedBuilder`](crate::builders::PanedBuilder) which can be used to create [`Paned`] objects.
39    pub fn builder() -> PanedBuilder {
40        PanedBuilder::new()
41    }
42
43    /// Append a widget in the paned.
44    /// ## `child`
45    /// a [`gtk::Widget`][crate::gtk::Widget] to append.
46    #[doc(alias = "panel_paned_append")]
47    pub fn append(&self, child: &impl IsA<gtk::Widget>) {
48        unsafe {
49            ffi::panel_paned_append(self.to_glib_none().0, child.as_ref().to_glib_none().0);
50        }
51    }
52
53    /// Gets the number of children in the paned.
54    ///
55    /// # Returns
56    ///
57    /// the number of children.
58    #[doc(alias = "panel_paned_get_n_children")]
59    #[doc(alias = "get_n_children")]
60    pub fn n_children(&self) -> u32 {
61        unsafe { ffi::panel_paned_get_n_children(self.to_glib_none().0) }
62    }
63
64    /// Gets the child at position `nth`.
65    /// ## `nth`
66    /// the child position
67    ///
68    /// # Returns
69    ///
70    /// a [`gtk::Widget`][crate::gtk::Widget] or [`None`]
71    #[doc(alias = "panel_paned_get_nth_child")]
72    #[doc(alias = "get_nth_child")]
73    pub fn nth_child(&self, nth: u32) -> Option<gtk::Widget> {
74        unsafe { from_glib_none(ffi::panel_paned_get_nth_child(self.to_glib_none().0, nth)) }
75    }
76
77    /// Inserts a widget at position in the paned.
78    /// ## `position`
79    /// the position
80    /// ## `child`
81    /// a [`gtk::Widget`][crate::gtk::Widget] to insert.
82    #[doc(alias = "panel_paned_insert")]
83    pub fn insert(&self, position: i32, child: &impl IsA<gtk::Widget>) {
84        unsafe {
85            ffi::panel_paned_insert(
86                self.to_glib_none().0,
87                position,
88                child.as_ref().to_glib_none().0,
89            );
90        }
91    }
92
93    /// Inserts a widget afer `sibling` in the paned.
94    /// ## `child`
95    /// a [`gtk::Widget`][crate::gtk::Widget] to insert.
96    /// ## `sibling`
97    /// the widget after which to insert.
98    #[doc(alias = "panel_paned_insert_after")]
99    pub fn insert_after(&self, child: &impl IsA<gtk::Widget>, sibling: &impl IsA<gtk::Widget>) {
100        unsafe {
101            ffi::panel_paned_insert_after(
102                self.to_glib_none().0,
103                child.as_ref().to_glib_none().0,
104                sibling.as_ref().to_glib_none().0,
105            );
106        }
107    }
108
109    /// Prepends a widget in the paned.
110    /// ## `child`
111    /// a [`gtk::Widget`][crate::gtk::Widget] to prepend.
112    #[doc(alias = "panel_paned_prepend")]
113    pub fn prepend(&self, child: &impl IsA<gtk::Widget>) {
114        unsafe {
115            ffi::panel_paned_prepend(self.to_glib_none().0, child.as_ref().to_glib_none().0);
116        }
117    }
118
119    /// Removes a widget from the paned.
120    /// ## `child`
121    /// a [`gtk::Widget`][crate::gtk::Widget]
122    #[doc(alias = "panel_paned_remove")]
123    pub fn remove(&self, child: &impl IsA<gtk::Widget>) {
124        unsafe {
125            ffi::panel_paned_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
126        }
127    }
128}
129
130impl Default for Paned {
131    fn default() -> Self {
132        Self::new()
133    }
134}
135
136// rustdoc-stripper-ignore-next
137/// A [builder-pattern] type to construct [`Paned`] objects.
138///
139/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
140#[must_use = "The builder must be built to be used"]
141pub struct PanedBuilder {
142    builder: glib::object::ObjectBuilder<'static, Paned>,
143}
144
145impl PanedBuilder {
146    fn new() -> Self {
147        Self {
148            builder: glib::object::Object::builder(),
149        }
150    }
151
152    /// Whether the widget or any of its descendents can accept
153    /// the input focus.
154    ///
155    /// This property is meant to be set by widget implementations,
156    /// typically in their instance init function.
157    pub fn can_focus(self, can_focus: bool) -> Self {
158        Self {
159            builder: self.builder.property("can-focus", can_focus),
160        }
161    }
162
163    /// Whether the widget can receive pointer events.
164    pub fn can_target(self, can_target: bool) -> Self {
165        Self {
166            builder: self.builder.property("can-target", can_target),
167        }
168    }
169
170    /// A list of css classes applied to this widget.
171    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
172        Self {
173            builder: self.builder.property("css-classes", css_classes.into()),
174        }
175    }
176
177    /// The name of this widget in the CSS tree.
178    ///
179    /// This property is meant to be set by widget implementations,
180    /// typically in their instance init function.
181    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
182        Self {
183            builder: self.builder.property("css-name", css_name.into()),
184        }
185    }
186
187    /// The cursor used by `widget`.
188    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
189        Self {
190            builder: self.builder.property("cursor", cursor.clone()),
191        }
192    }
193
194    /// Whether the widget should grab focus when it is clicked with the mouse.
195    ///
196    /// This property is only relevant for widgets that can take focus.
197    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
198        Self {
199            builder: self.builder.property("focus-on-click", focus_on_click),
200        }
201    }
202
203    /// Whether this widget itself will accept the input focus.
204    pub fn focusable(self, focusable: bool) -> Self {
205        Self {
206            builder: self.builder.property("focusable", focusable),
207        }
208    }
209
210    /// How to distribute horizontal space if widget gets extra space.
211    pub fn halign(self, halign: gtk::Align) -> Self {
212        Self {
213            builder: self.builder.property("halign", halign),
214        }
215    }
216
217    /// Enables or disables the emission of the [signal`Gtk`::query-tooltip]
218    /// signal on `widget`.
219    ///
220    /// A true value indicates that `widget` can have a tooltip, in this case
221    /// the widget will be queried using [signal`Gtk`::query-tooltip] to
222    /// determine whether it will provide a tooltip or not.
223    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
224        Self {
225            builder: self.builder.property("has-tooltip", has_tooltip),
226        }
227    }
228
229    /// Overrides for height request of the widget.
230    ///
231    /// If this is -1, the natural request will be used.
232    pub fn height_request(self, height_request: i32) -> Self {
233        Self {
234            builder: self.builder.property("height-request", height_request),
235        }
236    }
237
238    /// Whether to expand horizontally.
239    pub fn hexpand(self, hexpand: bool) -> Self {
240        Self {
241            builder: self.builder.property("hexpand", hexpand),
242        }
243    }
244
245    /// Whether to use the `hexpand` property.
246    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
247        Self {
248            builder: self.builder.property("hexpand-set", hexpand_set),
249        }
250    }
251
252    /// The [class`Gtk`] instance to use to compute
253    /// the preferred size of the widget, and allocate its children.
254    ///
255    /// This property is meant to be set by widget implementations,
256    /// typically in their instance init function.
257    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
258        Self {
259            builder: self
260                .builder
261                .property("layout-manager", layout_manager.clone().upcast()),
262        }
263    }
264
265    /// Makes this widget act like a modal dialog, with respect to
266    /// event delivery.
267    ///
268    /// Global event controllers will not handle events with targets
269    /// inside the widget, unless they are set up to ignore propagation
270    /// limits. See [method`Gtk`.set_propagation_limit].
271    #[cfg(feature = "gtk_v4_18")]
272    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
273    pub fn limit_events(self, limit_events: bool) -> Self {
274        Self {
275            builder: self.builder.property("limit-events", limit_events),
276        }
277    }
278
279    /// Margin on bottom side of widget.
280    ///
281    /// This property adds margin outside of the widget's normal size
282    /// request, the margin will be added in addition to the size from
283    /// [method`Gtk`.set_size_request] for example.
284    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
285        Self {
286            builder: self.builder.property("margin-bottom", margin_bottom),
287        }
288    }
289
290    /// Margin on end of widget, horizontally.
291    ///
292    /// This property supports left-to-right and right-to-left text
293    /// directions.
294    ///
295    /// This property adds margin outside of the widget's normal size
296    /// request, the margin will be added in addition to the size from
297    /// [method`Gtk`.set_size_request] for example.
298    pub fn margin_end(self, margin_end: i32) -> Self {
299        Self {
300            builder: self.builder.property("margin-end", margin_end),
301        }
302    }
303
304    /// Margin on start of widget, horizontally.
305    ///
306    /// This property supports left-to-right and right-to-left text
307    /// directions.
308    ///
309    /// This property adds margin outside of the widget's normal size
310    /// request, the margin will be added in addition to the size from
311    /// [method`Gtk`.set_size_request] for example.
312    pub fn margin_start(self, margin_start: i32) -> Self {
313        Self {
314            builder: self.builder.property("margin-start", margin_start),
315        }
316    }
317
318    /// Margin on top side of widget.
319    ///
320    /// This property adds margin outside of the widget's normal size
321    /// request, the margin will be added in addition to the size from
322    /// [method`Gtk`.set_size_request] for example.
323    pub fn margin_top(self, margin_top: i32) -> Self {
324        Self {
325            builder: self.builder.property("margin-top", margin_top),
326        }
327    }
328
329    /// The name of the widget.
330    pub fn name(self, name: impl Into<glib::GString>) -> Self {
331        Self {
332            builder: self.builder.property("name", name.into()),
333        }
334    }
335
336    /// The requested opacity of the widget.
337    pub fn opacity(self, opacity: f64) -> Self {
338        Self {
339            builder: self.builder.property("opacity", opacity),
340        }
341    }
342
343    /// How content outside the widget's content area is treated.
344    ///
345    /// This property is meant to be set by widget implementations,
346    /// typically in their instance init function.
347    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
348        Self {
349            builder: self.builder.property("overflow", overflow),
350        }
351    }
352
353    /// Whether the widget will receive the default action when it is focused.
354    pub fn receives_default(self, receives_default: bool) -> Self {
355        Self {
356            builder: self.builder.property("receives-default", receives_default),
357        }
358    }
359
360    /// Whether the widget responds to input.
361    pub fn sensitive(self, sensitive: bool) -> Self {
362        Self {
363            builder: self.builder.property("sensitive", sensitive),
364        }
365    }
366
367    /// Sets the text of tooltip to be the given string, which is marked up
368    /// with Pango markup.
369    ///
370    /// Also see [method`Gtk`.set_markup].
371    ///
372    /// This is a convenience property which will take care of getting the
373    /// tooltip shown if the given string is not `NULL`:
374    /// [property`Gtk`:has-tooltip] will automatically be set to true
375    /// and there will be taken care of [signal`Gtk`::query-tooltip] in
376    /// the default signal handler.
377    ///
378    /// Note that if both [property`Gtk`:tooltip-text] and
379    /// [property`Gtk`:tooltip-markup] are set, the last one wins.
380    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
381        Self {
382            builder: self
383                .builder
384                .property("tooltip-markup", tooltip_markup.into()),
385        }
386    }
387
388    /// Sets the text of tooltip to be the given string.
389    ///
390    /// Also see [method`Gtk`.set_text].
391    ///
392    /// This is a convenience property which will take care of getting the
393    /// tooltip shown if the given string is not `NULL`:
394    /// [property`Gtk`:has-tooltip] will automatically be set to true
395    /// and there will be taken care of [signal`Gtk`::query-tooltip] in
396    /// the default signal handler.
397    ///
398    /// Note that if both [property`Gtk`:tooltip-text] and
399    /// [property`Gtk`:tooltip-markup] are set, the last one wins.
400    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
401        Self {
402            builder: self.builder.property("tooltip-text", tooltip_text.into()),
403        }
404    }
405
406    /// How to distribute vertical space if widget gets extra space.
407    pub fn valign(self, valign: gtk::Align) -> Self {
408        Self {
409            builder: self.builder.property("valign", valign),
410        }
411    }
412
413    /// Whether to expand vertically.
414    pub fn vexpand(self, vexpand: bool) -> Self {
415        Self {
416            builder: self.builder.property("vexpand", vexpand),
417        }
418    }
419
420    /// Whether to use the `vexpand` property.
421    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
422        Self {
423            builder: self.builder.property("vexpand-set", vexpand_set),
424        }
425    }
426
427    /// Whether the widget is visible.
428    pub fn visible(self, visible: bool) -> Self {
429        Self {
430            builder: self.builder.property("visible", visible),
431        }
432    }
433
434    /// Overrides for width request of the widget.
435    ///
436    /// If this is -1, the natural request will be used.
437    pub fn width_request(self, width_request: i32) -> Self {
438        Self {
439            builder: self.builder.property("width-request", width_request),
440        }
441    }
442
443    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
444    ///
445    /// The accessible role cannot be changed once set.
446    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
447        Self {
448            builder: self.builder.property("accessible-role", accessible_role),
449        }
450    }
451
452    /// The orientation of the orientable.
453    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
454        Self {
455            builder: self.builder.property("orientation", orientation),
456        }
457    }
458
459    // rustdoc-stripper-ignore-next
460    /// Build the [`Paned`].
461    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
462    pub fn build(self) -> Paned {
463        assert_initialized_main_thread!();
464        self.builder.build()
465    }
466}