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