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::StaticType;
14use glib::ToValue;
15use glib::Value;
16use glib_sys;
17use gobject_sys;
18use gtk_sys;
19use libc;
20use signal::Inhibit;
21use std::boxed::Box as Box_;
22use std::fmt;
23use std::mem::transmute;
24use Align;
25use Buildable;
26use Container;
27use IconSize;
28use Orientable;
29use Orientation;
30use ResizeMode;
31use ToolItem;
32use ToolShell;
33use ToolbarStyle;
34use Widget;
35
36glib_wrapper! {
37 pub struct Toolbar(Object<gtk_sys::GtkToolbar, gtk_sys::GtkToolbarClass, ToolbarClass>) @extends Container, Widget, @implements Buildable, Orientable, ToolShell;
38
39 match fn {
40 get_type => || gtk_sys::gtk_toolbar_get_type(),
41 }
42}
43
44impl Toolbar {
45 pub fn new() -> Toolbar {
46 assert_initialized_main_thread!();
47 unsafe { Widget::from_glib_none(gtk_sys::gtk_toolbar_new()).unsafe_cast() }
48 }
49}
50
51impl Default for Toolbar {
52 fn default() -> Self {
53 Self::new()
54 }
55}
56
57pub struct ToolbarBuilder {
58 icon_size: Option<IconSize>,
59 icon_size_set: Option<bool>,
60 show_arrow: Option<bool>,
61 toolbar_style: Option<ToolbarStyle>,
62 border_width: Option<u32>,
63 child: Option<Widget>,
64 resize_mode: Option<ResizeMode>,
65 app_paintable: Option<bool>,
66 can_default: Option<bool>,
67 can_focus: Option<bool>,
68 events: Option<gdk::EventMask>,
69 expand: Option<bool>,
70 #[cfg(any(feature = "v3_20", feature = "dox"))]
71 focus_on_click: Option<bool>,
72 halign: Option<Align>,
73 has_default: Option<bool>,
74 has_focus: Option<bool>,
75 has_tooltip: Option<bool>,
76 height_request: Option<i32>,
77 hexpand: Option<bool>,
78 hexpand_set: Option<bool>,
79 is_focus: Option<bool>,
80 margin: Option<i32>,
81 margin_bottom: Option<i32>,
82 margin_end: Option<i32>,
83 margin_start: Option<i32>,
84 margin_top: Option<i32>,
85 name: Option<String>,
86 no_show_all: Option<bool>,
87 opacity: Option<f64>,
88 parent: Option<Container>,
89 receives_default: Option<bool>,
90 sensitive: Option<bool>,
91 tooltip_markup: Option<String>,
93 tooltip_text: Option<String>,
94 valign: Option<Align>,
95 vexpand: Option<bool>,
96 vexpand_set: Option<bool>,
97 visible: Option<bool>,
98 width_request: Option<i32>,
99}
100
101impl ToolbarBuilder {
102 pub fn new() -> Self {
103 Self {
104 icon_size: None,
105 icon_size_set: None,
106 show_arrow: None,
107 toolbar_style: None,
108 border_width: None,
109 child: None,
110 resize_mode: None,
111 app_paintable: None,
112 can_default: None,
113 can_focus: None,
114 events: None,
115 expand: None,
116 #[cfg(any(feature = "v3_20", feature = "dox"))]
117 focus_on_click: None,
118 halign: None,
119 has_default: None,
120 has_focus: None,
121 has_tooltip: None,
122 height_request: None,
123 hexpand: None,
124 hexpand_set: None,
125 is_focus: None,
126 margin: None,
127 margin_bottom: None,
128 margin_end: None,
129 margin_start: None,
130 margin_top: None,
131 name: None,
132 no_show_all: None,
133 opacity: None,
134 parent: None,
135 receives_default: None,
136 sensitive: None,
137 tooltip_markup: None,
138 tooltip_text: None,
139 valign: None,
140 vexpand: None,
141 vexpand_set: None,
142 visible: None,
143 width_request: None,
144 }
145 }
146
147 pub fn build(self) -> Toolbar {
148 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
149 if let Some(ref icon_size) = self.icon_size {
150 properties.push(("icon-size", icon_size));
151 }
152 if let Some(ref icon_size_set) = self.icon_size_set {
153 properties.push(("icon-size-set", icon_size_set));
154 }
155 if let Some(ref show_arrow) = self.show_arrow {
156 properties.push(("show-arrow", show_arrow));
157 }
158 if let Some(ref toolbar_style) = self.toolbar_style {
159 properties.push(("toolbar-style", toolbar_style));
160 }
161 if let Some(ref border_width) = self.border_width {
162 properties.push(("border-width", border_width));
163 }
164 if let Some(ref child) = self.child {
165 properties.push(("child", child));
166 }
167 if let Some(ref resize_mode) = self.resize_mode {
168 properties.push(("resize-mode", resize_mode));
169 }
170 if let Some(ref app_paintable) = self.app_paintable {
171 properties.push(("app-paintable", app_paintable));
172 }
173 if let Some(ref can_default) = self.can_default {
174 properties.push(("can-default", can_default));
175 }
176 if let Some(ref can_focus) = self.can_focus {
177 properties.push(("can-focus", can_focus));
178 }
179 if let Some(ref events) = self.events {
180 properties.push(("events", events));
181 }
182 if let Some(ref expand) = self.expand {
183 properties.push(("expand", expand));
184 }
185 #[cfg(any(feature = "v3_20", feature = "dox"))]
186 {
187 if let Some(ref focus_on_click) = self.focus_on_click {
188 properties.push(("focus-on-click", focus_on_click));
189 }
190 }
191 if let Some(ref halign) = self.halign {
192 properties.push(("halign", halign));
193 }
194 if let Some(ref has_default) = self.has_default {
195 properties.push(("has-default", has_default));
196 }
197 if let Some(ref has_focus) = self.has_focus {
198 properties.push(("has-focus", has_focus));
199 }
200 if let Some(ref has_tooltip) = self.has_tooltip {
201 properties.push(("has-tooltip", has_tooltip));
202 }
203 if let Some(ref height_request) = self.height_request {
204 properties.push(("height-request", height_request));
205 }
206 if let Some(ref hexpand) = self.hexpand {
207 properties.push(("hexpand", hexpand));
208 }
209 if let Some(ref hexpand_set) = self.hexpand_set {
210 properties.push(("hexpand-set", hexpand_set));
211 }
212 if let Some(ref is_focus) = self.is_focus {
213 properties.push(("is-focus", is_focus));
214 }
215 if let Some(ref margin) = self.margin {
216 properties.push(("margin", margin));
217 }
218 if let Some(ref margin_bottom) = self.margin_bottom {
219 properties.push(("margin-bottom", margin_bottom));
220 }
221 if let Some(ref margin_end) = self.margin_end {
222 properties.push(("margin-end", margin_end));
223 }
224 if let Some(ref margin_start) = self.margin_start {
225 properties.push(("margin-start", margin_start));
226 }
227 if let Some(ref margin_top) = self.margin_top {
228 properties.push(("margin-top", margin_top));
229 }
230 if let Some(ref name) = self.name {
231 properties.push(("name", name));
232 }
233 if let Some(ref no_show_all) = self.no_show_all {
234 properties.push(("no-show-all", no_show_all));
235 }
236 if let Some(ref opacity) = self.opacity {
237 properties.push(("opacity", opacity));
238 }
239 if let Some(ref parent) = self.parent {
240 properties.push(("parent", parent));
241 }
242 if let Some(ref receives_default) = self.receives_default {
243 properties.push(("receives-default", receives_default));
244 }
245 if let Some(ref sensitive) = self.sensitive {
246 properties.push(("sensitive", sensitive));
247 }
248 if let Some(ref tooltip_markup) = self.tooltip_markup {
249 properties.push(("tooltip-markup", tooltip_markup));
250 }
251 if let Some(ref tooltip_text) = self.tooltip_text {
252 properties.push(("tooltip-text", tooltip_text));
253 }
254 if let Some(ref valign) = self.valign {
255 properties.push(("valign", valign));
256 }
257 if let Some(ref vexpand) = self.vexpand {
258 properties.push(("vexpand", vexpand));
259 }
260 if let Some(ref vexpand_set) = self.vexpand_set {
261 properties.push(("vexpand-set", vexpand_set));
262 }
263 if let Some(ref visible) = self.visible {
264 properties.push(("visible", visible));
265 }
266 if let Some(ref width_request) = self.width_request {
267 properties.push(("width-request", width_request));
268 }
269 glib::Object::new(Toolbar::static_type(), &properties)
270 .expect("object new")
271 .downcast()
272 .expect("downcast")
273 }
274
275 pub fn icon_size(mut self, icon_size: IconSize) -> Self {
276 self.icon_size = Some(icon_size);
277 self
278 }
279
280 pub fn icon_size_set(mut self, icon_size_set: bool) -> Self {
281 self.icon_size_set = Some(icon_size_set);
282 self
283 }
284
285 pub fn show_arrow(mut self, show_arrow: bool) -> Self {
286 self.show_arrow = Some(show_arrow);
287 self
288 }
289
290 pub fn toolbar_style(mut self, toolbar_style: ToolbarStyle) -> Self {
291 self.toolbar_style = Some(toolbar_style);
292 self
293 }
294
295 pub fn border_width(mut self, border_width: u32) -> Self {
296 self.border_width = Some(border_width);
297 self
298 }
299
300 pub fn child(mut self, child: &Widget) -> Self {
301 self.child = Some(child.clone());
302 self
303 }
304
305 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
306 self.resize_mode = Some(resize_mode);
307 self
308 }
309
310 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
311 self.app_paintable = Some(app_paintable);
312 self
313 }
314
315 pub fn can_default(mut self, can_default: bool) -> Self {
316 self.can_default = Some(can_default);
317 self
318 }
319
320 pub fn can_focus(mut self, can_focus: bool) -> Self {
321 self.can_focus = Some(can_focus);
322 self
323 }
324
325 pub fn events(mut self, events: gdk::EventMask) -> Self {
326 self.events = Some(events);
327 self
328 }
329
330 pub fn expand(mut self, expand: bool) -> Self {
331 self.expand = Some(expand);
332 self
333 }
334
335 #[cfg(any(feature = "v3_20", feature = "dox"))]
336 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
337 self.focus_on_click = Some(focus_on_click);
338 self
339 }
340
341 pub fn halign(mut self, halign: Align) -> Self {
342 self.halign = Some(halign);
343 self
344 }
345
346 pub fn has_default(mut self, has_default: bool) -> Self {
347 self.has_default = Some(has_default);
348 self
349 }
350
351 pub fn has_focus(mut self, has_focus: bool) -> Self {
352 self.has_focus = Some(has_focus);
353 self
354 }
355
356 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
357 self.has_tooltip = Some(has_tooltip);
358 self
359 }
360
361 pub fn height_request(mut self, height_request: i32) -> Self {
362 self.height_request = Some(height_request);
363 self
364 }
365
366 pub fn hexpand(mut self, hexpand: bool) -> Self {
367 self.hexpand = Some(hexpand);
368 self
369 }
370
371 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
372 self.hexpand_set = Some(hexpand_set);
373 self
374 }
375
376 pub fn is_focus(mut self, is_focus: bool) -> Self {
377 self.is_focus = Some(is_focus);
378 self
379 }
380
381 pub fn margin(mut self, margin: i32) -> Self {
382 self.margin = Some(margin);
383 self
384 }
385
386 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
387 self.margin_bottom = Some(margin_bottom);
388 self
389 }
390
391 pub fn margin_end(mut self, margin_end: i32) -> Self {
392 self.margin_end = Some(margin_end);
393 self
394 }
395
396 pub fn margin_start(mut self, margin_start: i32) -> Self {
397 self.margin_start = Some(margin_start);
398 self
399 }
400
401 pub fn margin_top(mut self, margin_top: i32) -> Self {
402 self.margin_top = Some(margin_top);
403 self
404 }
405
406 pub fn name(mut self, name: &str) -> Self {
407 self.name = Some(name.to_string());
408 self
409 }
410
411 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
412 self.no_show_all = Some(no_show_all);
413 self
414 }
415
416 pub fn opacity(mut self, opacity: f64) -> Self {
417 self.opacity = Some(opacity);
418 self
419 }
420
421 pub fn parent(mut self, parent: &Container) -> Self {
422 self.parent = Some(parent.clone());
423 self
424 }
425
426 pub fn receives_default(mut self, receives_default: bool) -> Self {
427 self.receives_default = Some(receives_default);
428 self
429 }
430
431 pub fn sensitive(mut self, sensitive: bool) -> Self {
432 self.sensitive = Some(sensitive);
433 self
434 }
435
436 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
437 self.tooltip_markup = Some(tooltip_markup.to_string());
438 self
439 }
440
441 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
442 self.tooltip_text = Some(tooltip_text.to_string());
443 self
444 }
445
446 pub fn valign(mut self, valign: Align) -> Self {
447 self.valign = Some(valign);
448 self
449 }
450
451 pub fn vexpand(mut self, vexpand: bool) -> Self {
452 self.vexpand = Some(vexpand);
453 self
454 }
455
456 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
457 self.vexpand_set = Some(vexpand_set);
458 self
459 }
460
461 pub fn visible(mut self, visible: bool) -> Self {
462 self.visible = Some(visible);
463 self
464 }
465
466 pub fn width_request(mut self, width_request: i32) -> Self {
467 self.width_request = Some(width_request);
468 self
469 }
470}
471
472pub const NONE_TOOLBAR: Option<&Toolbar> = None;
473
474pub trait ToolbarExt: 'static {
475 fn get_drop_index(&self, x: i32, y: i32) -> i32;
476
477 fn get_item_index<P: IsA<ToolItem>>(&self, item: &P) -> i32;
478
479 fn get_n_items(&self) -> i32;
480
481 fn get_nth_item(&self, n: i32) -> Option<ToolItem>;
482
483 fn get_show_arrow(&self) -> bool;
484
485 fn insert<P: IsA<ToolItem>>(&self, item: &P, pos: i32);
486
487 fn set_drop_highlight_item<P: IsA<ToolItem>>(&self, tool_item: Option<&P>, index_: i32);
488
489 fn set_icon_size(&self, icon_size: IconSize);
490
491 fn set_show_arrow(&self, show_arrow: bool);
492
493 fn set_style(&self, style: ToolbarStyle);
494
495 fn unset_icon_size(&self);
496
497 fn unset_style(&self);
498
499 fn get_property_icon_size_set(&self) -> bool;
500
501 fn set_property_icon_size_set(&self, icon_size_set: bool);
502
503 fn get_property_toolbar_style(&self) -> ToolbarStyle;
504
505 fn set_property_toolbar_style(&self, toolbar_style: ToolbarStyle);
506
507 fn get_item_expand<T: IsA<Widget>>(&self, item: &T) -> bool;
508
509 fn set_item_expand<T: IsA<Widget>>(&self, item: &T, expand: bool);
510
511 fn get_item_homogeneous<T: IsA<Widget>>(&self, item: &T) -> bool;
512
513 fn set_item_homogeneous<T: IsA<Widget>>(&self, item: &T, homogeneous: bool);
514
515 fn connect_focus_home_or_end<F: Fn(&Self, bool) -> bool + 'static>(
516 &self,
517 f: F,
518 ) -> SignalHandlerId;
519
520 fn emit_focus_home_or_end(&self, focus_home: bool) -> bool;
521
522 fn connect_orientation_changed<F: Fn(&Self, Orientation) + 'static>(
523 &self,
524 f: F,
525 ) -> SignalHandlerId;
526
527 fn connect_popup_context_menu<F: Fn(&Self, i32, i32, i32) -> Inhibit + 'static>(
528 &self,
529 f: F,
530 ) -> SignalHandlerId;
531
532 fn connect_style_changed<F: Fn(&Self, ToolbarStyle) + 'static>(&self, f: F) -> SignalHandlerId;
533
534 fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
535
536 fn connect_property_icon_size_set_notify<F: Fn(&Self) + 'static>(
537 &self,
538 f: F,
539 ) -> SignalHandlerId;
540
541 fn connect_property_show_arrow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
542
543 fn connect_property_toolbar_style_notify<F: Fn(&Self) + 'static>(
544 &self,
545 f: F,
546 ) -> SignalHandlerId;
547}
548
549impl<O: IsA<Toolbar>> ToolbarExt for O {
550 fn get_drop_index(&self, x: i32, y: i32) -> i32 {
551 unsafe { gtk_sys::gtk_toolbar_get_drop_index(self.as_ref().to_glib_none().0, x, y) }
552 }
553
554 fn get_item_index<P: IsA<ToolItem>>(&self, item: &P) -> i32 {
555 unsafe {
556 gtk_sys::gtk_toolbar_get_item_index(
557 self.as_ref().to_glib_none().0,
558 item.as_ref().to_glib_none().0,
559 )
560 }
561 }
562
563 fn get_n_items(&self) -> i32 {
564 unsafe { gtk_sys::gtk_toolbar_get_n_items(self.as_ref().to_glib_none().0) }
565 }
566
567 fn get_nth_item(&self, n: i32) -> Option<ToolItem> {
568 unsafe {
569 from_glib_none(gtk_sys::gtk_toolbar_get_nth_item(
570 self.as_ref().to_glib_none().0,
571 n,
572 ))
573 }
574 }
575
576 fn get_show_arrow(&self) -> bool {
577 unsafe {
578 from_glib(gtk_sys::gtk_toolbar_get_show_arrow(
579 self.as_ref().to_glib_none().0,
580 ))
581 }
582 }
583
584 fn insert<P: IsA<ToolItem>>(&self, item: &P, pos: i32) {
585 unsafe {
586 gtk_sys::gtk_toolbar_insert(
587 self.as_ref().to_glib_none().0,
588 item.as_ref().to_glib_none().0,
589 pos,
590 );
591 }
592 }
593
594 fn set_drop_highlight_item<P: IsA<ToolItem>>(&self, tool_item: Option<&P>, index_: i32) {
595 unsafe {
596 gtk_sys::gtk_toolbar_set_drop_highlight_item(
597 self.as_ref().to_glib_none().0,
598 tool_item.map(|p| p.as_ref()).to_glib_none().0,
599 index_,
600 );
601 }
602 }
603
604 fn set_icon_size(&self, icon_size: IconSize) {
605 unsafe {
606 gtk_sys::gtk_toolbar_set_icon_size(self.as_ref().to_glib_none().0, icon_size.to_glib());
607 }
608 }
609
610 fn set_show_arrow(&self, show_arrow: bool) {
611 unsafe {
612 gtk_sys::gtk_toolbar_set_show_arrow(
613 self.as_ref().to_glib_none().0,
614 show_arrow.to_glib(),
615 );
616 }
617 }
618
619 fn set_style(&self, style: ToolbarStyle) {
620 unsafe {
621 gtk_sys::gtk_toolbar_set_style(self.as_ref().to_glib_none().0, style.to_glib());
622 }
623 }
624
625 fn unset_icon_size(&self) {
626 unsafe {
627 gtk_sys::gtk_toolbar_unset_icon_size(self.as_ref().to_glib_none().0);
628 }
629 }
630
631 fn unset_style(&self) {
632 unsafe {
633 gtk_sys::gtk_toolbar_unset_style(self.as_ref().to_glib_none().0);
634 }
635 }
636
637 fn get_property_icon_size_set(&self) -> bool {
638 unsafe {
639 let mut value = Value::from_type(<bool as StaticType>::static_type());
640 gobject_sys::g_object_get_property(
641 self.to_glib_none().0 as *mut gobject_sys::GObject,
642 b"icon-size-set\0".as_ptr() as *const _,
643 value.to_glib_none_mut().0,
644 );
645 value.get().unwrap()
646 }
647 }
648
649 fn set_property_icon_size_set(&self, icon_size_set: bool) {
650 unsafe {
651 gobject_sys::g_object_set_property(
652 self.to_glib_none().0 as *mut gobject_sys::GObject,
653 b"icon-size-set\0".as_ptr() as *const _,
654 Value::from(&icon_size_set).to_glib_none().0,
655 );
656 }
657 }
658
659 fn get_property_toolbar_style(&self) -> ToolbarStyle {
660 unsafe {
661 let mut value = Value::from_type(<ToolbarStyle as StaticType>::static_type());
662 gobject_sys::g_object_get_property(
663 self.to_glib_none().0 as *mut gobject_sys::GObject,
664 b"toolbar-style\0".as_ptr() as *const _,
665 value.to_glib_none_mut().0,
666 );
667 value.get().unwrap()
668 }
669 }
670
671 fn set_property_toolbar_style(&self, toolbar_style: ToolbarStyle) {
672 unsafe {
673 gobject_sys::g_object_set_property(
674 self.to_glib_none().0 as *mut gobject_sys::GObject,
675 b"toolbar-style\0".as_ptr() as *const _,
676 Value::from(&toolbar_style).to_glib_none().0,
677 );
678 }
679 }
680
681 fn get_item_expand<T: IsA<Widget>>(&self, item: &T) -> bool {
682 unsafe {
683 let mut value = Value::from_type(<bool as StaticType>::static_type());
684 gtk_sys::gtk_container_child_get_property(
685 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
686 item.to_glib_none().0 as *mut _,
687 b"expand\0".as_ptr() as *const _,
688 value.to_glib_none_mut().0,
689 );
690 value.get().unwrap()
691 }
692 }
693
694 fn set_item_expand<T: IsA<Widget>>(&self, item: &T, expand: bool) {
695 unsafe {
696 gtk_sys::gtk_container_child_set_property(
697 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
698 item.to_glib_none().0 as *mut _,
699 b"expand\0".as_ptr() as *const _,
700 Value::from(&expand).to_glib_none().0,
701 );
702 }
703 }
704
705 fn get_item_homogeneous<T: IsA<Widget>>(&self, item: &T) -> bool {
706 unsafe {
707 let mut value = Value::from_type(<bool as StaticType>::static_type());
708 gtk_sys::gtk_container_child_get_property(
709 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
710 item.to_glib_none().0 as *mut _,
711 b"homogeneous\0".as_ptr() as *const _,
712 value.to_glib_none_mut().0,
713 );
714 value.get().unwrap()
715 }
716 }
717
718 fn set_item_homogeneous<T: IsA<Widget>>(&self, item: &T, homogeneous: bool) {
719 unsafe {
720 gtk_sys::gtk_container_child_set_property(
721 self.to_glib_none().0 as *mut gtk_sys::GtkContainer,
722 item.to_glib_none().0 as *mut _,
723 b"homogeneous\0".as_ptr() as *const _,
724 Value::from(&homogeneous).to_glib_none().0,
725 );
726 }
727 }
728
729 fn connect_focus_home_or_end<F: Fn(&Self, bool) -> bool + 'static>(
730 &self,
731 f: F,
732 ) -> SignalHandlerId {
733 unsafe extern "C" fn focus_home_or_end_trampoline<P, F: Fn(&P, bool) -> bool + 'static>(
734 this: *mut gtk_sys::GtkToolbar,
735 focus_home: glib_sys::gboolean,
736 f: glib_sys::gpointer,
737 ) -> glib_sys::gboolean
738 where
739 P: IsA<Toolbar>,
740 {
741 let f: &F = &*(f as *const F);
742 f(
743 &Toolbar::from_glib_borrow(this).unsafe_cast(),
744 from_glib(focus_home),
745 )
746 .to_glib()
747 }
748 unsafe {
749 let f: Box_<F> = Box_::new(f);
750 connect_raw(
751 self.as_ptr() as *mut _,
752 b"focus-home-or-end\0".as_ptr() as *const _,
753 Some(transmute(focus_home_or_end_trampoline::<Self, F> as usize)),
754 Box_::into_raw(f),
755 )
756 }
757 }
758
759 fn emit_focus_home_or_end(&self, focus_home: bool) -> bool {
760 let res = unsafe {
761 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
762 .emit("focus-home-or-end", &[&focus_home])
763 .unwrap()
764 };
765 res.unwrap().get().unwrap()
766 }
767
768 fn connect_orientation_changed<F: Fn(&Self, Orientation) + 'static>(
769 &self,
770 f: F,
771 ) -> SignalHandlerId {
772 unsafe extern "C" fn orientation_changed_trampoline<P, F: Fn(&P, Orientation) + 'static>(
773 this: *mut gtk_sys::GtkToolbar,
774 orientation: gtk_sys::GtkOrientation,
775 f: glib_sys::gpointer,
776 ) where
777 P: IsA<Toolbar>,
778 {
779 let f: &F = &*(f as *const F);
780 f(
781 &Toolbar::from_glib_borrow(this).unsafe_cast(),
782 from_glib(orientation),
783 )
784 }
785 unsafe {
786 let f: Box_<F> = Box_::new(f);
787 connect_raw(
788 self.as_ptr() as *mut _,
789 b"orientation-changed\0".as_ptr() as *const _,
790 Some(transmute(
791 orientation_changed_trampoline::<Self, F> as usize,
792 )),
793 Box_::into_raw(f),
794 )
795 }
796 }
797
798 fn connect_popup_context_menu<F: Fn(&Self, i32, i32, i32) -> Inhibit + 'static>(
799 &self,
800 f: F,
801 ) -> SignalHandlerId {
802 unsafe extern "C" fn popup_context_menu_trampoline<
803 P,
804 F: Fn(&P, i32, i32, i32) -> Inhibit + 'static,
805 >(
806 this: *mut gtk_sys::GtkToolbar,
807 x: libc::c_int,
808 y: libc::c_int,
809 button: libc::c_int,
810 f: glib_sys::gpointer,
811 ) -> glib_sys::gboolean
812 where
813 P: IsA<Toolbar>,
814 {
815 let f: &F = &*(f as *const F);
816 f(&Toolbar::from_glib_borrow(this).unsafe_cast(), x, y, button).to_glib()
817 }
818 unsafe {
819 let f: Box_<F> = Box_::new(f);
820 connect_raw(
821 self.as_ptr() as *mut _,
822 b"popup-context-menu\0".as_ptr() as *const _,
823 Some(transmute(popup_context_menu_trampoline::<Self, F> as usize)),
824 Box_::into_raw(f),
825 )
826 }
827 }
828
829 fn connect_style_changed<F: Fn(&Self, ToolbarStyle) + 'static>(&self, f: F) -> SignalHandlerId {
830 unsafe extern "C" fn style_changed_trampoline<P, F: Fn(&P, ToolbarStyle) + 'static>(
831 this: *mut gtk_sys::GtkToolbar,
832 style: gtk_sys::GtkToolbarStyle,
833 f: glib_sys::gpointer,
834 ) where
835 P: IsA<Toolbar>,
836 {
837 let f: &F = &*(f as *const F);
838 f(
839 &Toolbar::from_glib_borrow(this).unsafe_cast(),
840 from_glib(style),
841 )
842 }
843 unsafe {
844 let f: Box_<F> = Box_::new(f);
845 connect_raw(
846 self.as_ptr() as *mut _,
847 b"style-changed\0".as_ptr() as *const _,
848 Some(transmute(style_changed_trampoline::<Self, F> as usize)),
849 Box_::into_raw(f),
850 )
851 }
852 }
853
854 fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
855 unsafe extern "C" fn notify_icon_size_trampoline<P, F: Fn(&P) + 'static>(
856 this: *mut gtk_sys::GtkToolbar,
857 _param_spec: glib_sys::gpointer,
858 f: glib_sys::gpointer,
859 ) where
860 P: IsA<Toolbar>,
861 {
862 let f: &F = &*(f as *const F);
863 f(&Toolbar::from_glib_borrow(this).unsafe_cast())
864 }
865 unsafe {
866 let f: Box_<F> = Box_::new(f);
867 connect_raw(
868 self.as_ptr() as *mut _,
869 b"notify::icon-size\0".as_ptr() as *const _,
870 Some(transmute(notify_icon_size_trampoline::<Self, F> as usize)),
871 Box_::into_raw(f),
872 )
873 }
874 }
875
876 fn connect_property_icon_size_set_notify<F: Fn(&Self) + 'static>(
877 &self,
878 f: F,
879 ) -> SignalHandlerId {
880 unsafe extern "C" fn notify_icon_size_set_trampoline<P, F: Fn(&P) + 'static>(
881 this: *mut gtk_sys::GtkToolbar,
882 _param_spec: glib_sys::gpointer,
883 f: glib_sys::gpointer,
884 ) where
885 P: IsA<Toolbar>,
886 {
887 let f: &F = &*(f as *const F);
888 f(&Toolbar::from_glib_borrow(this).unsafe_cast())
889 }
890 unsafe {
891 let f: Box_<F> = Box_::new(f);
892 connect_raw(
893 self.as_ptr() as *mut _,
894 b"notify::icon-size-set\0".as_ptr() as *const _,
895 Some(transmute(
896 notify_icon_size_set_trampoline::<Self, F> as usize,
897 )),
898 Box_::into_raw(f),
899 )
900 }
901 }
902
903 fn connect_property_show_arrow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
904 unsafe extern "C" fn notify_show_arrow_trampoline<P, F: Fn(&P) + 'static>(
905 this: *mut gtk_sys::GtkToolbar,
906 _param_spec: glib_sys::gpointer,
907 f: glib_sys::gpointer,
908 ) where
909 P: IsA<Toolbar>,
910 {
911 let f: &F = &*(f as *const F);
912 f(&Toolbar::from_glib_borrow(this).unsafe_cast())
913 }
914 unsafe {
915 let f: Box_<F> = Box_::new(f);
916 connect_raw(
917 self.as_ptr() as *mut _,
918 b"notify::show-arrow\0".as_ptr() as *const _,
919 Some(transmute(notify_show_arrow_trampoline::<Self, F> as usize)),
920 Box_::into_raw(f),
921 )
922 }
923 }
924
925 fn connect_property_toolbar_style_notify<F: Fn(&Self) + 'static>(
926 &self,
927 f: F,
928 ) -> SignalHandlerId {
929 unsafe extern "C" fn notify_toolbar_style_trampoline<P, F: Fn(&P) + 'static>(
930 this: *mut gtk_sys::GtkToolbar,
931 _param_spec: glib_sys::gpointer,
932 f: glib_sys::gpointer,
933 ) where
934 P: IsA<Toolbar>,
935 {
936 let f: &F = &*(f as *const F);
937 f(&Toolbar::from_glib_borrow(this).unsafe_cast())
938 }
939 unsafe {
940 let f: Box_<F> = Box_::new(f);
941 connect_raw(
942 self.as_ptr() as *mut _,
943 b"notify::toolbar-style\0".as_ptr() as *const _,
944 Some(transmute(
945 notify_toolbar_style_trampoline::<Self, F> as usize,
946 )),
947 Box_::into_raw(f),
948 )
949 }
950 }
951}
952
953impl fmt::Display for Toolbar {
954 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
955 write!(f, "Toolbar")
956 }
957}