1use gdk;
6use glib;
7use glib::object::Cast;
8use glib::object::IsA;
9use glib::object::ObjectExt;
10use glib::signal::connect_raw;
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13use glib::GString;
14use glib::StaticType;
15use glib::ToValue;
16use glib_sys;
17use gobject_sys;
18use gtk_sys;
19use std::boxed::Box as Box_;
20use std::fmt;
21use std::mem::transmute;
22use Actionable;
23use Align;
24use Bin;
25use Buildable;
26use Container;
27use ResizeMode;
28use ToolItem;
29use Widget;
30
31glib_wrapper! {
32 pub struct ToolButton(Object<gtk_sys::GtkToolButton, gtk_sys::GtkToolButtonClass, ToolButtonClass>) @extends ToolItem, Bin, Container, Widget, @implements Buildable, Actionable;
33
34 match fn {
35 get_type => || gtk_sys::gtk_tool_button_get_type(),
36 }
37}
38
39impl ToolButton {
40 pub fn new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> ToolButton {
41 assert_initialized_main_thread!();
42 unsafe {
43 ToolItem::from_glib_none(gtk_sys::gtk_tool_button_new(
44 icon_widget.map(|p| p.as_ref()).to_glib_none().0,
45 label.to_glib_none().0,
46 ))
47 .unsafe_cast()
48 }
49 }
50}
51
52pub struct ToolButtonBuilder {
53 icon_name: Option<String>,
54 icon_widget: Option<Widget>,
55 label: Option<String>,
56 label_widget: Option<Widget>,
57 use_underline: Option<bool>,
58 is_important: Option<bool>,
59 visible_horizontal: Option<bool>,
60 visible_vertical: Option<bool>,
61 border_width: Option<u32>,
62 child: Option<Widget>,
63 resize_mode: Option<ResizeMode>,
64 app_paintable: Option<bool>,
65 can_default: Option<bool>,
66 can_focus: Option<bool>,
67 events: Option<gdk::EventMask>,
68 expand: Option<bool>,
69 #[cfg(any(feature = "v3_20", feature = "dox"))]
70 focus_on_click: Option<bool>,
71 halign: Option<Align>,
72 has_default: Option<bool>,
73 has_focus: Option<bool>,
74 has_tooltip: Option<bool>,
75 height_request: Option<i32>,
76 hexpand: Option<bool>,
77 hexpand_set: Option<bool>,
78 is_focus: Option<bool>,
79 margin: Option<i32>,
80 margin_bottom: Option<i32>,
81 margin_end: Option<i32>,
82 margin_start: Option<i32>,
83 margin_top: Option<i32>,
84 name: Option<String>,
85 no_show_all: Option<bool>,
86 opacity: Option<f64>,
87 parent: Option<Container>,
88 receives_default: Option<bool>,
89 sensitive: Option<bool>,
90 tooltip_markup: Option<String>,
92 tooltip_text: Option<String>,
93 valign: Option<Align>,
94 vexpand: Option<bool>,
95 vexpand_set: Option<bool>,
96 visible: Option<bool>,
97 width_request: Option<i32>,
98}
99
100impl ToolButtonBuilder {
101 pub fn new() -> Self {
102 Self {
103 icon_name: None,
104 icon_widget: None,
105 label: None,
106 label_widget: None,
107 use_underline: None,
108 is_important: None,
109 visible_horizontal: None,
110 visible_vertical: None,
111 border_width: None,
112 child: None,
113 resize_mode: None,
114 app_paintable: None,
115 can_default: None,
116 can_focus: None,
117 events: None,
118 expand: None,
119 #[cfg(any(feature = "v3_20", feature = "dox"))]
120 focus_on_click: None,
121 halign: None,
122 has_default: None,
123 has_focus: None,
124 has_tooltip: None,
125 height_request: None,
126 hexpand: None,
127 hexpand_set: None,
128 is_focus: None,
129 margin: None,
130 margin_bottom: None,
131 margin_end: None,
132 margin_start: None,
133 margin_top: None,
134 name: None,
135 no_show_all: None,
136 opacity: None,
137 parent: None,
138 receives_default: None,
139 sensitive: None,
140 tooltip_markup: None,
141 tooltip_text: None,
142 valign: None,
143 vexpand: None,
144 vexpand_set: None,
145 visible: None,
146 width_request: None,
147 }
148 }
149
150 pub fn build(self) -> ToolButton {
151 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
152 if let Some(ref icon_name) = self.icon_name {
153 properties.push(("icon-name", icon_name));
154 }
155 if let Some(ref icon_widget) = self.icon_widget {
156 properties.push(("icon-widget", icon_widget));
157 }
158 if let Some(ref label) = self.label {
159 properties.push(("label", label));
160 }
161 if let Some(ref label_widget) = self.label_widget {
162 properties.push(("label-widget", label_widget));
163 }
164 if let Some(ref use_underline) = self.use_underline {
165 properties.push(("use-underline", use_underline));
166 }
167 if let Some(ref is_important) = self.is_important {
168 properties.push(("is-important", is_important));
169 }
170 if let Some(ref visible_horizontal) = self.visible_horizontal {
171 properties.push(("visible-horizontal", visible_horizontal));
172 }
173 if let Some(ref visible_vertical) = self.visible_vertical {
174 properties.push(("visible-vertical", visible_vertical));
175 }
176 if let Some(ref border_width) = self.border_width {
177 properties.push(("border-width", border_width));
178 }
179 if let Some(ref child) = self.child {
180 properties.push(("child", child));
181 }
182 if let Some(ref resize_mode) = self.resize_mode {
183 properties.push(("resize-mode", resize_mode));
184 }
185 if let Some(ref app_paintable) = self.app_paintable {
186 properties.push(("app-paintable", app_paintable));
187 }
188 if let Some(ref can_default) = self.can_default {
189 properties.push(("can-default", can_default));
190 }
191 if let Some(ref can_focus) = self.can_focus {
192 properties.push(("can-focus", can_focus));
193 }
194 if let Some(ref events) = self.events {
195 properties.push(("events", events));
196 }
197 if let Some(ref expand) = self.expand {
198 properties.push(("expand", expand));
199 }
200 #[cfg(any(feature = "v3_20", feature = "dox"))]
201 {
202 if let Some(ref focus_on_click) = self.focus_on_click {
203 properties.push(("focus-on-click", focus_on_click));
204 }
205 }
206 if let Some(ref halign) = self.halign {
207 properties.push(("halign", halign));
208 }
209 if let Some(ref has_default) = self.has_default {
210 properties.push(("has-default", has_default));
211 }
212 if let Some(ref has_focus) = self.has_focus {
213 properties.push(("has-focus", has_focus));
214 }
215 if let Some(ref has_tooltip) = self.has_tooltip {
216 properties.push(("has-tooltip", has_tooltip));
217 }
218 if let Some(ref height_request) = self.height_request {
219 properties.push(("height-request", height_request));
220 }
221 if let Some(ref hexpand) = self.hexpand {
222 properties.push(("hexpand", hexpand));
223 }
224 if let Some(ref hexpand_set) = self.hexpand_set {
225 properties.push(("hexpand-set", hexpand_set));
226 }
227 if let Some(ref is_focus) = self.is_focus {
228 properties.push(("is-focus", is_focus));
229 }
230 if let Some(ref margin) = self.margin {
231 properties.push(("margin", margin));
232 }
233 if let Some(ref margin_bottom) = self.margin_bottom {
234 properties.push(("margin-bottom", margin_bottom));
235 }
236 if let Some(ref margin_end) = self.margin_end {
237 properties.push(("margin-end", margin_end));
238 }
239 if let Some(ref margin_start) = self.margin_start {
240 properties.push(("margin-start", margin_start));
241 }
242 if let Some(ref margin_top) = self.margin_top {
243 properties.push(("margin-top", margin_top));
244 }
245 if let Some(ref name) = self.name {
246 properties.push(("name", name));
247 }
248 if let Some(ref no_show_all) = self.no_show_all {
249 properties.push(("no-show-all", no_show_all));
250 }
251 if let Some(ref opacity) = self.opacity {
252 properties.push(("opacity", opacity));
253 }
254 if let Some(ref parent) = self.parent {
255 properties.push(("parent", parent));
256 }
257 if let Some(ref receives_default) = self.receives_default {
258 properties.push(("receives-default", receives_default));
259 }
260 if let Some(ref sensitive) = self.sensitive {
261 properties.push(("sensitive", sensitive));
262 }
263 if let Some(ref tooltip_markup) = self.tooltip_markup {
264 properties.push(("tooltip-markup", tooltip_markup));
265 }
266 if let Some(ref tooltip_text) = self.tooltip_text {
267 properties.push(("tooltip-text", tooltip_text));
268 }
269 if let Some(ref valign) = self.valign {
270 properties.push(("valign", valign));
271 }
272 if let Some(ref vexpand) = self.vexpand {
273 properties.push(("vexpand", vexpand));
274 }
275 if let Some(ref vexpand_set) = self.vexpand_set {
276 properties.push(("vexpand-set", vexpand_set));
277 }
278 if let Some(ref visible) = self.visible {
279 properties.push(("visible", visible));
280 }
281 if let Some(ref width_request) = self.width_request {
282 properties.push(("width-request", width_request));
283 }
284 glib::Object::new(ToolButton::static_type(), &properties)
285 .expect("object new")
286 .downcast()
287 .expect("downcast")
288 }
289
290 pub fn icon_name(mut self, icon_name: &str) -> Self {
291 self.icon_name = Some(icon_name.to_string());
292 self
293 }
294
295 pub fn icon_widget(mut self, icon_widget: &Widget) -> Self {
296 self.icon_widget = Some(icon_widget.clone());
297 self
298 }
299
300 pub fn label(mut self, label: &str) -> Self {
301 self.label = Some(label.to_string());
302 self
303 }
304
305 pub fn label_widget(mut self, label_widget: &Widget) -> Self {
306 self.label_widget = Some(label_widget.clone());
307 self
308 }
309
310 pub fn use_underline(mut self, use_underline: bool) -> Self {
311 self.use_underline = Some(use_underline);
312 self
313 }
314
315 pub fn is_important(mut self, is_important: bool) -> Self {
316 self.is_important = Some(is_important);
317 self
318 }
319
320 pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self {
321 self.visible_horizontal = Some(visible_horizontal);
322 self
323 }
324
325 pub fn visible_vertical(mut self, visible_vertical: bool) -> Self {
326 self.visible_vertical = Some(visible_vertical);
327 self
328 }
329
330 pub fn border_width(mut self, border_width: u32) -> Self {
331 self.border_width = Some(border_width);
332 self
333 }
334
335 pub fn child(mut self, child: &Widget) -> Self {
336 self.child = Some(child.clone());
337 self
338 }
339
340 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
341 self.resize_mode = Some(resize_mode);
342 self
343 }
344
345 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
346 self.app_paintable = Some(app_paintable);
347 self
348 }
349
350 pub fn can_default(mut self, can_default: bool) -> Self {
351 self.can_default = Some(can_default);
352 self
353 }
354
355 pub fn can_focus(mut self, can_focus: bool) -> Self {
356 self.can_focus = Some(can_focus);
357 self
358 }
359
360 pub fn events(mut self, events: gdk::EventMask) -> Self {
361 self.events = Some(events);
362 self
363 }
364
365 pub fn expand(mut self, expand: bool) -> Self {
366 self.expand = Some(expand);
367 self
368 }
369
370 #[cfg(any(feature = "v3_20", feature = "dox"))]
371 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
372 self.focus_on_click = Some(focus_on_click);
373 self
374 }
375
376 pub fn halign(mut self, halign: Align) -> Self {
377 self.halign = Some(halign);
378 self
379 }
380
381 pub fn has_default(mut self, has_default: bool) -> Self {
382 self.has_default = Some(has_default);
383 self
384 }
385
386 pub fn has_focus(mut self, has_focus: bool) -> Self {
387 self.has_focus = Some(has_focus);
388 self
389 }
390
391 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
392 self.has_tooltip = Some(has_tooltip);
393 self
394 }
395
396 pub fn height_request(mut self, height_request: i32) -> Self {
397 self.height_request = Some(height_request);
398 self
399 }
400
401 pub fn hexpand(mut self, hexpand: bool) -> Self {
402 self.hexpand = Some(hexpand);
403 self
404 }
405
406 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
407 self.hexpand_set = Some(hexpand_set);
408 self
409 }
410
411 pub fn is_focus(mut self, is_focus: bool) -> Self {
412 self.is_focus = Some(is_focus);
413 self
414 }
415
416 pub fn margin(mut self, margin: i32) -> Self {
417 self.margin = Some(margin);
418 self
419 }
420
421 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
422 self.margin_bottom = Some(margin_bottom);
423 self
424 }
425
426 pub fn margin_end(mut self, margin_end: i32) -> Self {
427 self.margin_end = Some(margin_end);
428 self
429 }
430
431 pub fn margin_start(mut self, margin_start: i32) -> Self {
432 self.margin_start = Some(margin_start);
433 self
434 }
435
436 pub fn margin_top(mut self, margin_top: i32) -> Self {
437 self.margin_top = Some(margin_top);
438 self
439 }
440
441 pub fn name(mut self, name: &str) -> Self {
442 self.name = Some(name.to_string());
443 self
444 }
445
446 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
447 self.no_show_all = Some(no_show_all);
448 self
449 }
450
451 pub fn opacity(mut self, opacity: f64) -> Self {
452 self.opacity = Some(opacity);
453 self
454 }
455
456 pub fn parent(mut self, parent: &Container) -> Self {
457 self.parent = Some(parent.clone());
458 self
459 }
460
461 pub fn receives_default(mut self, receives_default: bool) -> Self {
462 self.receives_default = Some(receives_default);
463 self
464 }
465
466 pub fn sensitive(mut self, sensitive: bool) -> Self {
467 self.sensitive = Some(sensitive);
468 self
469 }
470
471 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
472 self.tooltip_markup = Some(tooltip_markup.to_string());
473 self
474 }
475
476 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
477 self.tooltip_text = Some(tooltip_text.to_string());
478 self
479 }
480
481 pub fn valign(mut self, valign: Align) -> Self {
482 self.valign = Some(valign);
483 self
484 }
485
486 pub fn vexpand(mut self, vexpand: bool) -> Self {
487 self.vexpand = Some(vexpand);
488 self
489 }
490
491 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
492 self.vexpand_set = Some(vexpand_set);
493 self
494 }
495
496 pub fn visible(mut self, visible: bool) -> Self {
497 self.visible = Some(visible);
498 self
499 }
500
501 pub fn width_request(mut self, width_request: i32) -> Self {
502 self.width_request = Some(width_request);
503 self
504 }
505}
506
507pub const NONE_TOOL_BUTTON: Option<&ToolButton> = None;
508
509pub trait ToolButtonExt: 'static {
510 fn get_icon_name(&self) -> Option<GString>;
511
512 fn get_icon_widget(&self) -> Option<Widget>;
513
514 fn get_label(&self) -> Option<GString>;
515
516 fn get_label_widget(&self) -> Option<Widget>;
517
518 fn get_use_underline(&self) -> bool;
519
520 fn set_icon_name(&self, icon_name: Option<&str>);
521
522 fn set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>);
523
524 fn set_label(&self, label: Option<&str>);
525
526 fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>);
527
528 fn set_use_underline(&self, use_underline: bool);
529
530 fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
531
532 fn emit_clicked(&self);
533
534 fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
535
536 fn connect_property_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
537
538 fn connect_property_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
539
540 fn connect_property_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F)
541 -> SignalHandlerId;
542
543 fn connect_property_use_underline_notify<F: Fn(&Self) + 'static>(
544 &self,
545 f: F,
546 ) -> SignalHandlerId;
547}
548
549impl<O: IsA<ToolButton>> ToolButtonExt for O {
550 fn get_icon_name(&self) -> Option<GString> {
551 unsafe {
552 from_glib_none(gtk_sys::gtk_tool_button_get_icon_name(
553 self.as_ref().to_glib_none().0,
554 ))
555 }
556 }
557
558 fn get_icon_widget(&self) -> Option<Widget> {
559 unsafe {
560 from_glib_none(gtk_sys::gtk_tool_button_get_icon_widget(
561 self.as_ref().to_glib_none().0,
562 ))
563 }
564 }
565
566 fn get_label(&self) -> Option<GString> {
567 unsafe {
568 from_glib_none(gtk_sys::gtk_tool_button_get_label(
569 self.as_ref().to_glib_none().0,
570 ))
571 }
572 }
573
574 fn get_label_widget(&self) -> Option<Widget> {
575 unsafe {
576 from_glib_none(gtk_sys::gtk_tool_button_get_label_widget(
577 self.as_ref().to_glib_none().0,
578 ))
579 }
580 }
581
582 fn get_use_underline(&self) -> bool {
583 unsafe {
584 from_glib(gtk_sys::gtk_tool_button_get_use_underline(
585 self.as_ref().to_glib_none().0,
586 ))
587 }
588 }
589
590 fn set_icon_name(&self, icon_name: Option<&str>) {
591 unsafe {
592 gtk_sys::gtk_tool_button_set_icon_name(
593 self.as_ref().to_glib_none().0,
594 icon_name.to_glib_none().0,
595 );
596 }
597 }
598
599 fn set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>) {
600 unsafe {
601 gtk_sys::gtk_tool_button_set_icon_widget(
602 self.as_ref().to_glib_none().0,
603 icon_widget.map(|p| p.as_ref()).to_glib_none().0,
604 );
605 }
606 }
607
608 fn set_label(&self, label: Option<&str>) {
609 unsafe {
610 gtk_sys::gtk_tool_button_set_label(
611 self.as_ref().to_glib_none().0,
612 label.to_glib_none().0,
613 );
614 }
615 }
616
617 fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>) {
618 unsafe {
619 gtk_sys::gtk_tool_button_set_label_widget(
620 self.as_ref().to_glib_none().0,
621 label_widget.map(|p| p.as_ref()).to_glib_none().0,
622 );
623 }
624 }
625
626 fn set_use_underline(&self, use_underline: bool) {
627 unsafe {
628 gtk_sys::gtk_tool_button_set_use_underline(
629 self.as_ref().to_glib_none().0,
630 use_underline.to_glib(),
631 );
632 }
633 }
634
635 fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
636 unsafe extern "C" fn clicked_trampoline<P, F: Fn(&P) + 'static>(
637 this: *mut gtk_sys::GtkToolButton,
638 f: glib_sys::gpointer,
639 ) where
640 P: IsA<ToolButton>,
641 {
642 let f: &F = &*(f as *const F);
643 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
644 }
645 unsafe {
646 let f: Box_<F> = Box_::new(f);
647 connect_raw(
648 self.as_ptr() as *mut _,
649 b"clicked\0".as_ptr() as *const _,
650 Some(transmute(clicked_trampoline::<Self, F> as usize)),
651 Box_::into_raw(f),
652 )
653 }
654 }
655
656 fn emit_clicked(&self) {
657 let _ = unsafe {
658 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
659 .emit("clicked", &[])
660 .unwrap()
661 };
662 }
663
664 fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
665 unsafe extern "C" fn notify_icon_name_trampoline<P, F: Fn(&P) + 'static>(
666 this: *mut gtk_sys::GtkToolButton,
667 _param_spec: glib_sys::gpointer,
668 f: glib_sys::gpointer,
669 ) where
670 P: IsA<ToolButton>,
671 {
672 let f: &F = &*(f as *const F);
673 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
674 }
675 unsafe {
676 let f: Box_<F> = Box_::new(f);
677 connect_raw(
678 self.as_ptr() as *mut _,
679 b"notify::icon-name\0".as_ptr() as *const _,
680 Some(transmute(notify_icon_name_trampoline::<Self, F> as usize)),
681 Box_::into_raw(f),
682 )
683 }
684 }
685
686 fn connect_property_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
687 unsafe extern "C" fn notify_icon_widget_trampoline<P, F: Fn(&P) + 'static>(
688 this: *mut gtk_sys::GtkToolButton,
689 _param_spec: glib_sys::gpointer,
690 f: glib_sys::gpointer,
691 ) where
692 P: IsA<ToolButton>,
693 {
694 let f: &F = &*(f as *const F);
695 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
696 }
697 unsafe {
698 let f: Box_<F> = Box_::new(f);
699 connect_raw(
700 self.as_ptr() as *mut _,
701 b"notify::icon-widget\0".as_ptr() as *const _,
702 Some(transmute(notify_icon_widget_trampoline::<Self, F> as usize)),
703 Box_::into_raw(f),
704 )
705 }
706 }
707
708 fn connect_property_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
709 unsafe extern "C" fn notify_label_trampoline<P, F: Fn(&P) + 'static>(
710 this: *mut gtk_sys::GtkToolButton,
711 _param_spec: glib_sys::gpointer,
712 f: glib_sys::gpointer,
713 ) where
714 P: IsA<ToolButton>,
715 {
716 let f: &F = &*(f as *const F);
717 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
718 }
719 unsafe {
720 let f: Box_<F> = Box_::new(f);
721 connect_raw(
722 self.as_ptr() as *mut _,
723 b"notify::label\0".as_ptr() as *const _,
724 Some(transmute(notify_label_trampoline::<Self, F> as usize)),
725 Box_::into_raw(f),
726 )
727 }
728 }
729
730 fn connect_property_label_widget_notify<F: Fn(&Self) + 'static>(
731 &self,
732 f: F,
733 ) -> SignalHandlerId {
734 unsafe extern "C" fn notify_label_widget_trampoline<P, F: Fn(&P) + 'static>(
735 this: *mut gtk_sys::GtkToolButton,
736 _param_spec: glib_sys::gpointer,
737 f: glib_sys::gpointer,
738 ) where
739 P: IsA<ToolButton>,
740 {
741 let f: &F = &*(f as *const F);
742 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
743 }
744 unsafe {
745 let f: Box_<F> = Box_::new(f);
746 connect_raw(
747 self.as_ptr() as *mut _,
748 b"notify::label-widget\0".as_ptr() as *const _,
749 Some(transmute(
750 notify_label_widget_trampoline::<Self, F> as usize,
751 )),
752 Box_::into_raw(f),
753 )
754 }
755 }
756
757 fn connect_property_use_underline_notify<F: Fn(&Self) + 'static>(
758 &self,
759 f: F,
760 ) -> SignalHandlerId {
761 unsafe extern "C" fn notify_use_underline_trampoline<P, F: Fn(&P) + 'static>(
762 this: *mut gtk_sys::GtkToolButton,
763 _param_spec: glib_sys::gpointer,
764 f: glib_sys::gpointer,
765 ) where
766 P: IsA<ToolButton>,
767 {
768 let f: &F = &*(f as *const F);
769 f(&ToolButton::from_glib_borrow(this).unsafe_cast())
770 }
771 unsafe {
772 let f: Box_<F> = Box_::new(f);
773 connect_raw(
774 self.as_ptr() as *mut _,
775 b"notify::use-underline\0".as_ptr() as *const _,
776 Some(transmute(
777 notify_use_underline_trampoline::<Self, F> as usize,
778 )),
779 Box_::into_raw(f),
780 )
781 }
782 }
783}
784
785impl fmt::Display for ToolButton {
786 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
787 write!(f, "ToolButton")
788 }
789}