1use gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::StaticType;
10use glib::ToValue;
11use gtk_sys;
12use std::fmt;
13use Actionable;
14use Align;
15use Bin;
16use Buildable;
17use Container;
18use RadioButton;
19use ResizeMode;
20use ToggleToolButton;
21use ToolButton;
22use ToolItem;
23use Widget;
24
25glib_wrapper! {
26 pub struct RadioToolButton(Object<gtk_sys::GtkRadioToolButton, gtk_sys::GtkRadioToolButtonClass, RadioToolButtonClass>) @extends ToggleToolButton, ToolButton, ToolItem, Bin, Container, Widget, @implements Buildable, Actionable;
27
28 match fn {
29 get_type => || gtk_sys::gtk_radio_tool_button_get_type(),
30 }
31}
32
33impl RadioToolButton {
34 pub fn new_from_widget<P: IsA<RadioToolButton>>(group: &P) -> RadioToolButton {
35 skip_assert_initialized!();
36 unsafe {
37 ToolItem::from_glib_none(gtk_sys::gtk_radio_tool_button_new_from_widget(
38 group.as_ref().to_glib_none().0,
39 ))
40 .unsafe_cast()
41 }
42 }
43}
44
45pub struct RadioToolButtonBuilder {
46 active: Option<bool>,
47 icon_name: Option<String>,
48 icon_widget: Option<Widget>,
49 label: Option<String>,
50 label_widget: Option<Widget>,
51 use_underline: Option<bool>,
52 is_important: Option<bool>,
53 visible_horizontal: Option<bool>,
54 visible_vertical: Option<bool>,
55 border_width: Option<u32>,
56 child: Option<Widget>,
57 resize_mode: Option<ResizeMode>,
58 app_paintable: Option<bool>,
59 can_default: Option<bool>,
60 can_focus: Option<bool>,
61 events: Option<gdk::EventMask>,
62 expand: Option<bool>,
63 #[cfg(any(feature = "v3_20", feature = "dox"))]
64 focus_on_click: Option<bool>,
65 halign: Option<Align>,
66 has_default: Option<bool>,
67 has_focus: Option<bool>,
68 has_tooltip: Option<bool>,
69 height_request: Option<i32>,
70 hexpand: Option<bool>,
71 hexpand_set: Option<bool>,
72 is_focus: Option<bool>,
73 margin: Option<i32>,
74 margin_bottom: Option<i32>,
75 margin_end: Option<i32>,
76 margin_start: Option<i32>,
77 margin_top: Option<i32>,
78 name: Option<String>,
79 no_show_all: Option<bool>,
80 opacity: Option<f64>,
81 parent: Option<Container>,
82 receives_default: Option<bool>,
83 sensitive: Option<bool>,
84 tooltip_markup: Option<String>,
86 tooltip_text: Option<String>,
87 valign: Option<Align>,
88 vexpand: Option<bool>,
89 vexpand_set: Option<bool>,
90 visible: Option<bool>,
91 width_request: Option<i32>,
92}
93
94impl RadioToolButtonBuilder {
95 pub fn new() -> Self {
96 Self {
97 active: None,
98 icon_name: None,
99 icon_widget: None,
100 label: None,
101 label_widget: None,
102 use_underline: None,
103 is_important: None,
104 visible_horizontal: None,
105 visible_vertical: None,
106 border_width: None,
107 child: None,
108 resize_mode: None,
109 app_paintable: None,
110 can_default: None,
111 can_focus: None,
112 events: None,
113 expand: None,
114 #[cfg(any(feature = "v3_20", feature = "dox"))]
115 focus_on_click: None,
116 halign: None,
117 has_default: None,
118 has_focus: None,
119 has_tooltip: None,
120 height_request: None,
121 hexpand: None,
122 hexpand_set: None,
123 is_focus: None,
124 margin: None,
125 margin_bottom: None,
126 margin_end: None,
127 margin_start: None,
128 margin_top: None,
129 name: None,
130 no_show_all: None,
131 opacity: None,
132 parent: None,
133 receives_default: None,
134 sensitive: None,
135 tooltip_markup: None,
136 tooltip_text: None,
137 valign: None,
138 vexpand: None,
139 vexpand_set: None,
140 visible: None,
141 width_request: None,
142 }
143 }
144
145 pub fn build(self) -> RadioToolButton {
146 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
147 if let Some(ref active) = self.active {
148 properties.push(("active", active));
149 }
150 if let Some(ref icon_name) = self.icon_name {
151 properties.push(("icon-name", icon_name));
152 }
153 if let Some(ref icon_widget) = self.icon_widget {
154 properties.push(("icon-widget", icon_widget));
155 }
156 if let Some(ref label) = self.label {
157 properties.push(("label", label));
158 }
159 if let Some(ref label_widget) = self.label_widget {
160 properties.push(("label-widget", label_widget));
161 }
162 if let Some(ref use_underline) = self.use_underline {
163 properties.push(("use-underline", use_underline));
164 }
165 if let Some(ref is_important) = self.is_important {
166 properties.push(("is-important", is_important));
167 }
168 if let Some(ref visible_horizontal) = self.visible_horizontal {
169 properties.push(("visible-horizontal", visible_horizontal));
170 }
171 if let Some(ref visible_vertical) = self.visible_vertical {
172 properties.push(("visible-vertical", visible_vertical));
173 }
174 if let Some(ref border_width) = self.border_width {
175 properties.push(("border-width", border_width));
176 }
177 if let Some(ref child) = self.child {
178 properties.push(("child", child));
179 }
180 if let Some(ref resize_mode) = self.resize_mode {
181 properties.push(("resize-mode", resize_mode));
182 }
183 if let Some(ref app_paintable) = self.app_paintable {
184 properties.push(("app-paintable", app_paintable));
185 }
186 if let Some(ref can_default) = self.can_default {
187 properties.push(("can-default", can_default));
188 }
189 if let Some(ref can_focus) = self.can_focus {
190 properties.push(("can-focus", can_focus));
191 }
192 if let Some(ref events) = self.events {
193 properties.push(("events", events));
194 }
195 if let Some(ref expand) = self.expand {
196 properties.push(("expand", expand));
197 }
198 #[cfg(any(feature = "v3_20", feature = "dox"))]
199 {
200 if let Some(ref focus_on_click) = self.focus_on_click {
201 properties.push(("focus-on-click", focus_on_click));
202 }
203 }
204 if let Some(ref halign) = self.halign {
205 properties.push(("halign", halign));
206 }
207 if let Some(ref has_default) = self.has_default {
208 properties.push(("has-default", has_default));
209 }
210 if let Some(ref has_focus) = self.has_focus {
211 properties.push(("has-focus", has_focus));
212 }
213 if let Some(ref has_tooltip) = self.has_tooltip {
214 properties.push(("has-tooltip", has_tooltip));
215 }
216 if let Some(ref height_request) = self.height_request {
217 properties.push(("height-request", height_request));
218 }
219 if let Some(ref hexpand) = self.hexpand {
220 properties.push(("hexpand", hexpand));
221 }
222 if let Some(ref hexpand_set) = self.hexpand_set {
223 properties.push(("hexpand-set", hexpand_set));
224 }
225 if let Some(ref is_focus) = self.is_focus {
226 properties.push(("is-focus", is_focus));
227 }
228 if let Some(ref margin) = self.margin {
229 properties.push(("margin", margin));
230 }
231 if let Some(ref margin_bottom) = self.margin_bottom {
232 properties.push(("margin-bottom", margin_bottom));
233 }
234 if let Some(ref margin_end) = self.margin_end {
235 properties.push(("margin-end", margin_end));
236 }
237 if let Some(ref margin_start) = self.margin_start {
238 properties.push(("margin-start", margin_start));
239 }
240 if let Some(ref margin_top) = self.margin_top {
241 properties.push(("margin-top", margin_top));
242 }
243 if let Some(ref name) = self.name {
244 properties.push(("name", name));
245 }
246 if let Some(ref no_show_all) = self.no_show_all {
247 properties.push(("no-show-all", no_show_all));
248 }
249 if let Some(ref opacity) = self.opacity {
250 properties.push(("opacity", opacity));
251 }
252 if let Some(ref parent) = self.parent {
253 properties.push(("parent", parent));
254 }
255 if let Some(ref receives_default) = self.receives_default {
256 properties.push(("receives-default", receives_default));
257 }
258 if let Some(ref sensitive) = self.sensitive {
259 properties.push(("sensitive", sensitive));
260 }
261 if let Some(ref tooltip_markup) = self.tooltip_markup {
262 properties.push(("tooltip-markup", tooltip_markup));
263 }
264 if let Some(ref tooltip_text) = self.tooltip_text {
265 properties.push(("tooltip-text", tooltip_text));
266 }
267 if let Some(ref valign) = self.valign {
268 properties.push(("valign", valign));
269 }
270 if let Some(ref vexpand) = self.vexpand {
271 properties.push(("vexpand", vexpand));
272 }
273 if let Some(ref vexpand_set) = self.vexpand_set {
274 properties.push(("vexpand-set", vexpand_set));
275 }
276 if let Some(ref visible) = self.visible {
277 properties.push(("visible", visible));
278 }
279 if let Some(ref width_request) = self.width_request {
280 properties.push(("width-request", width_request));
281 }
282 glib::Object::new(RadioToolButton::static_type(), &properties)
283 .expect("object new")
284 .downcast()
285 .expect("downcast")
286 }
287
288 pub fn active(mut self, active: bool) -> Self {
289 self.active = Some(active);
290 self
291 }
292
293 pub fn icon_name(mut self, icon_name: &str) -> Self {
294 self.icon_name = Some(icon_name.to_string());
295 self
296 }
297
298 pub fn icon_widget(mut self, icon_widget: &Widget) -> Self {
299 self.icon_widget = Some(icon_widget.clone());
300 self
301 }
302
303 pub fn label(mut self, label: &str) -> Self {
304 self.label = Some(label.to_string());
305 self
306 }
307
308 pub fn label_widget(mut self, label_widget: &Widget) -> Self {
309 self.label_widget = Some(label_widget.clone());
310 self
311 }
312
313 pub fn use_underline(mut self, use_underline: bool) -> Self {
314 self.use_underline = Some(use_underline);
315 self
316 }
317
318 pub fn is_important(mut self, is_important: bool) -> Self {
319 self.is_important = Some(is_important);
320 self
321 }
322
323 pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self {
324 self.visible_horizontal = Some(visible_horizontal);
325 self
326 }
327
328 pub fn visible_vertical(mut self, visible_vertical: bool) -> Self {
329 self.visible_vertical = Some(visible_vertical);
330 self
331 }
332
333 pub fn border_width(mut self, border_width: u32) -> Self {
334 self.border_width = Some(border_width);
335 self
336 }
337
338 pub fn child(mut self, child: &Widget) -> Self {
339 self.child = Some(child.clone());
340 self
341 }
342
343 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
344 self.resize_mode = Some(resize_mode);
345 self
346 }
347
348 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
349 self.app_paintable = Some(app_paintable);
350 self
351 }
352
353 pub fn can_default(mut self, can_default: bool) -> Self {
354 self.can_default = Some(can_default);
355 self
356 }
357
358 pub fn can_focus(mut self, can_focus: bool) -> Self {
359 self.can_focus = Some(can_focus);
360 self
361 }
362
363 pub fn events(mut self, events: gdk::EventMask) -> Self {
364 self.events = Some(events);
365 self
366 }
367
368 pub fn expand(mut self, expand: bool) -> Self {
369 self.expand = Some(expand);
370 self
371 }
372
373 #[cfg(any(feature = "v3_20", feature = "dox"))]
374 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
375 self.focus_on_click = Some(focus_on_click);
376 self
377 }
378
379 pub fn halign(mut self, halign: Align) -> Self {
380 self.halign = Some(halign);
381 self
382 }
383
384 pub fn has_default(mut self, has_default: bool) -> Self {
385 self.has_default = Some(has_default);
386 self
387 }
388
389 pub fn has_focus(mut self, has_focus: bool) -> Self {
390 self.has_focus = Some(has_focus);
391 self
392 }
393
394 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
395 self.has_tooltip = Some(has_tooltip);
396 self
397 }
398
399 pub fn height_request(mut self, height_request: i32) -> Self {
400 self.height_request = Some(height_request);
401 self
402 }
403
404 pub fn hexpand(mut self, hexpand: bool) -> Self {
405 self.hexpand = Some(hexpand);
406 self
407 }
408
409 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
410 self.hexpand_set = Some(hexpand_set);
411 self
412 }
413
414 pub fn is_focus(mut self, is_focus: bool) -> Self {
415 self.is_focus = Some(is_focus);
416 self
417 }
418
419 pub fn margin(mut self, margin: i32) -> Self {
420 self.margin = Some(margin);
421 self
422 }
423
424 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
425 self.margin_bottom = Some(margin_bottom);
426 self
427 }
428
429 pub fn margin_end(mut self, margin_end: i32) -> Self {
430 self.margin_end = Some(margin_end);
431 self
432 }
433
434 pub fn margin_start(mut self, margin_start: i32) -> Self {
435 self.margin_start = Some(margin_start);
436 self
437 }
438
439 pub fn margin_top(mut self, margin_top: i32) -> Self {
440 self.margin_top = Some(margin_top);
441 self
442 }
443
444 pub fn name(mut self, name: &str) -> Self {
445 self.name = Some(name.to_string());
446 self
447 }
448
449 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
450 self.no_show_all = Some(no_show_all);
451 self
452 }
453
454 pub fn opacity(mut self, opacity: f64) -> Self {
455 self.opacity = Some(opacity);
456 self
457 }
458
459 pub fn parent(mut self, parent: &Container) -> Self {
460 self.parent = Some(parent.clone());
461 self
462 }
463
464 pub fn receives_default(mut self, receives_default: bool) -> Self {
465 self.receives_default = Some(receives_default);
466 self
467 }
468
469 pub fn sensitive(mut self, sensitive: bool) -> Self {
470 self.sensitive = Some(sensitive);
471 self
472 }
473
474 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
475 self.tooltip_markup = Some(tooltip_markup.to_string());
476 self
477 }
478
479 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
480 self.tooltip_text = Some(tooltip_text.to_string());
481 self
482 }
483
484 pub fn valign(mut self, valign: Align) -> Self {
485 self.valign = Some(valign);
486 self
487 }
488
489 pub fn vexpand(mut self, vexpand: bool) -> Self {
490 self.vexpand = Some(vexpand);
491 self
492 }
493
494 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
495 self.vexpand_set = Some(vexpand_set);
496 self
497 }
498
499 pub fn visible(mut self, visible: bool) -> Self {
500 self.visible = Some(visible);
501 self
502 }
503
504 pub fn width_request(mut self, width_request: i32) -> Self {
505 self.width_request = Some(width_request);
506 self
507 }
508}
509
510pub const NONE_RADIO_TOOL_BUTTON: Option<&RadioToolButton> = None;
511
512pub trait RadioToolButtonExt: 'static {
513 fn get_group(&self) -> Vec<RadioButton>;
514}
515
516impl<O: IsA<RadioToolButton>> RadioToolButtonExt for O {
517 fn get_group(&self) -> Vec<RadioButton> {
518 unsafe {
519 FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_radio_tool_button_get_group(
520 self.as_ref().to_glib_none().0,
521 ))
522 }
523 }
524}
525
526impl fmt::Display for RadioToolButton {
527 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
528 write!(f, "RadioToolButton")
529 }
530}