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