1use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "PanelPaned")]
11 pub struct Paned(Object<ffi::PanelPaned, ffi::PanelPanedClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
12
13 match fn {
14 type_ => || ffi::panel_paned_get_type(),
15 }
16}
17
18impl Paned {
19 #[doc(alias = "panel_paned_new")]
20 pub fn new() -> Paned {
21 assert_initialized_main_thread!();
22 unsafe { gtk::Widget::from_glib_none(ffi::panel_paned_new()).unsafe_cast() }
23 }
24
25 pub fn builder() -> PanedBuilder {
30 PanedBuilder::new()
31 }
32
33 #[doc(alias = "panel_paned_append")]
34 pub fn append(&self, child: &impl IsA<gtk::Widget>) {
35 unsafe {
36 ffi::panel_paned_append(self.to_glib_none().0, child.as_ref().to_glib_none().0);
37 }
38 }
39
40 #[doc(alias = "panel_paned_get_n_children")]
41 #[doc(alias = "get_n_children")]
42 pub fn n_children(&self) -> u32 {
43 unsafe { ffi::panel_paned_get_n_children(self.to_glib_none().0) }
44 }
45
46 #[doc(alias = "panel_paned_get_nth_child")]
47 #[doc(alias = "get_nth_child")]
48 pub fn nth_child(&self, nth: u32) -> Option<gtk::Widget> {
49 unsafe { from_glib_none(ffi::panel_paned_get_nth_child(self.to_glib_none().0, nth)) }
50 }
51
52 #[doc(alias = "panel_paned_insert")]
53 pub fn insert(&self, position: i32, child: &impl IsA<gtk::Widget>) {
54 unsafe {
55 ffi::panel_paned_insert(
56 self.to_glib_none().0,
57 position,
58 child.as_ref().to_glib_none().0,
59 );
60 }
61 }
62
63 #[doc(alias = "panel_paned_insert_after")]
64 pub fn insert_after(&self, child: &impl IsA<gtk::Widget>, sibling: &impl IsA<gtk::Widget>) {
65 unsafe {
66 ffi::panel_paned_insert_after(
67 self.to_glib_none().0,
68 child.as_ref().to_glib_none().0,
69 sibling.as_ref().to_glib_none().0,
70 );
71 }
72 }
73
74 #[doc(alias = "panel_paned_prepend")]
75 pub fn prepend(&self, child: &impl IsA<gtk::Widget>) {
76 unsafe {
77 ffi::panel_paned_prepend(self.to_glib_none().0, child.as_ref().to_glib_none().0);
78 }
79 }
80
81 #[doc(alias = "panel_paned_remove")]
82 pub fn remove(&self, child: &impl IsA<gtk::Widget>) {
83 unsafe {
84 ffi::panel_paned_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
85 }
86 }
87}
88
89impl Default for Paned {
90 fn default() -> Self {
91 Self::new()
92 }
93}
94
95#[must_use = "The builder must be built to be used"]
100pub struct PanedBuilder {
101 builder: glib::object::ObjectBuilder<'static, Paned>,
102}
103
104impl PanedBuilder {
105 fn new() -> Self {
106 Self {
107 builder: glib::object::Object::builder(),
108 }
109 }
110
111 pub fn can_focus(self, can_focus: bool) -> Self {
112 Self {
113 builder: self.builder.property("can-focus", can_focus),
114 }
115 }
116
117 pub fn can_target(self, can_target: bool) -> Self {
118 Self {
119 builder: self.builder.property("can-target", can_target),
120 }
121 }
122
123 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
124 Self {
125 builder: self.builder.property("css-classes", css_classes.into()),
126 }
127 }
128
129 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
130 Self {
131 builder: self.builder.property("css-name", css_name.into()),
132 }
133 }
134
135 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
136 Self {
137 builder: self.builder.property("cursor", cursor.clone()),
138 }
139 }
140
141 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
142 Self {
143 builder: self.builder.property("focus-on-click", focus_on_click),
144 }
145 }
146
147 pub fn focusable(self, focusable: bool) -> Self {
148 Self {
149 builder: self.builder.property("focusable", focusable),
150 }
151 }
152
153 pub fn halign(self, halign: gtk::Align) -> Self {
154 Self {
155 builder: self.builder.property("halign", halign),
156 }
157 }
158
159 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
160 Self {
161 builder: self.builder.property("has-tooltip", has_tooltip),
162 }
163 }
164
165 pub fn height_request(self, height_request: i32) -> Self {
166 Self {
167 builder: self.builder.property("height-request", height_request),
168 }
169 }
170
171 pub fn hexpand(self, hexpand: bool) -> Self {
172 Self {
173 builder: self.builder.property("hexpand", hexpand),
174 }
175 }
176
177 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
178 Self {
179 builder: self.builder.property("hexpand-set", hexpand_set),
180 }
181 }
182
183 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
184 Self {
185 builder: self
186 .builder
187 .property("layout-manager", layout_manager.clone().upcast()),
188 }
189 }
190
191 #[cfg(feature = "gtk_v4_18")]
192 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
193 pub fn limit_events(self, limit_events: bool) -> Self {
194 Self {
195 builder: self.builder.property("limit-events", limit_events),
196 }
197 }
198
199 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
200 Self {
201 builder: self.builder.property("margin-bottom", margin_bottom),
202 }
203 }
204
205 pub fn margin_end(self, margin_end: i32) -> Self {
206 Self {
207 builder: self.builder.property("margin-end", margin_end),
208 }
209 }
210
211 pub fn margin_start(self, margin_start: i32) -> Self {
212 Self {
213 builder: self.builder.property("margin-start", margin_start),
214 }
215 }
216
217 pub fn margin_top(self, margin_top: i32) -> Self {
218 Self {
219 builder: self.builder.property("margin-top", margin_top),
220 }
221 }
222
223 pub fn name(self, name: impl Into<glib::GString>) -> Self {
224 Self {
225 builder: self.builder.property("name", name.into()),
226 }
227 }
228
229 pub fn opacity(self, opacity: f64) -> Self {
230 Self {
231 builder: self.builder.property("opacity", opacity),
232 }
233 }
234
235 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
236 Self {
237 builder: self.builder.property("overflow", overflow),
238 }
239 }
240
241 pub fn receives_default(self, receives_default: bool) -> Self {
242 Self {
243 builder: self.builder.property("receives-default", receives_default),
244 }
245 }
246
247 pub fn sensitive(self, sensitive: bool) -> Self {
248 Self {
249 builder: self.builder.property("sensitive", sensitive),
250 }
251 }
252
253 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
254 Self {
255 builder: self
256 .builder
257 .property("tooltip-markup", tooltip_markup.into()),
258 }
259 }
260
261 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
262 Self {
263 builder: self.builder.property("tooltip-text", tooltip_text.into()),
264 }
265 }
266
267 pub fn valign(self, valign: gtk::Align) -> Self {
268 Self {
269 builder: self.builder.property("valign", valign),
270 }
271 }
272
273 pub fn vexpand(self, vexpand: bool) -> Self {
274 Self {
275 builder: self.builder.property("vexpand", vexpand),
276 }
277 }
278
279 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
280 Self {
281 builder: self.builder.property("vexpand-set", vexpand_set),
282 }
283 }
284
285 pub fn visible(self, visible: bool) -> Self {
286 Self {
287 builder: self.builder.property("visible", visible),
288 }
289 }
290
291 pub fn width_request(self, width_request: i32) -> Self {
292 Self {
293 builder: self.builder.property("width-request", width_request),
294 }
295 }
296
297 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
298 Self {
299 builder: self.builder.property("accessible-role", accessible_role),
300 }
301 }
302
303 pub fn orientation(self, orientation: gtk::Orientation) -> Self {
304 Self {
305 builder: self.builder.property("orientation", orientation),
306 }
307 }
308
309 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
312 pub fn build(self) -> Paned {
313 assert_initialized_main_thread!();
314 self.builder.build()
315 }
316}