1use crate::{
6 ffi, Accessible, AccessibleRole, Align, ArrowType, Buildable, ConstraintTarget, LayoutManager,
7 Overflow, Popover, Widget,
8};
9#[cfg(feature = "v4_4")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
11use glib::object::ObjectType as _;
12use glib::{
13 prelude::*,
14 signal::{connect_raw, SignalHandlerId},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 #[doc(alias = "GtkMenuButton")]
21 pub struct MenuButton(Object<ffi::GtkMenuButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
22
23 match fn {
24 type_ => || ffi::gtk_menu_button_get_type(),
25 }
26}
27
28impl MenuButton {
29 #[doc(alias = "gtk_menu_button_new")]
30 pub fn new() -> MenuButton {
31 assert_initialized_main_thread!();
32 unsafe { Widget::from_glib_none(ffi::gtk_menu_button_new()).unsafe_cast() }
33 }
34
35 pub fn builder() -> MenuButtonBuilder {
40 MenuButtonBuilder::new()
41 }
42
43 #[cfg(feature = "v4_10")]
44 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
45 #[doc(alias = "gtk_menu_button_get_active")]
46 #[doc(alias = "get_active")]
47 #[doc(alias = "active")]
48 pub fn is_active(&self) -> bool {
49 unsafe { from_glib(ffi::gtk_menu_button_get_active(self.to_glib_none().0)) }
50 }
51
52 #[cfg(feature = "v4_4")]
53 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
54 #[doc(alias = "gtk_menu_button_get_always_show_arrow")]
55 #[doc(alias = "get_always_show_arrow")]
56 #[doc(alias = "always-show-arrow")]
57 pub fn must_always_show_arrow(&self) -> bool {
58 unsafe {
59 from_glib(ffi::gtk_menu_button_get_always_show_arrow(
60 self.to_glib_none().0,
61 ))
62 }
63 }
64
65 #[cfg(feature = "v4_12")]
66 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
67 #[doc(alias = "gtk_menu_button_get_can_shrink")]
68 #[doc(alias = "get_can_shrink")]
69 #[doc(alias = "can-shrink")]
70 pub fn can_shrink(&self) -> bool {
71 unsafe { from_glib(ffi::gtk_menu_button_get_can_shrink(self.to_glib_none().0)) }
72 }
73
74 #[cfg(feature = "v4_6")]
75 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
76 #[doc(alias = "gtk_menu_button_get_child")]
77 #[doc(alias = "get_child")]
78 pub fn child(&self) -> Option<Widget> {
79 unsafe { from_glib_none(ffi::gtk_menu_button_get_child(self.to_glib_none().0)) }
80 }
81
82 #[doc(alias = "gtk_menu_button_get_direction")]
83 #[doc(alias = "get_direction")]
84 pub fn direction(&self) -> ArrowType {
85 unsafe { from_glib(ffi::gtk_menu_button_get_direction(self.to_glib_none().0)) }
86 }
87
88 #[doc(alias = "gtk_menu_button_get_has_frame")]
89 #[doc(alias = "get_has_frame")]
90 #[doc(alias = "has-frame")]
91 pub fn has_frame(&self) -> bool {
92 unsafe { from_glib(ffi::gtk_menu_button_get_has_frame(self.to_glib_none().0)) }
93 }
94
95 #[doc(alias = "gtk_menu_button_get_icon_name")]
96 #[doc(alias = "get_icon_name")]
97 #[doc(alias = "icon-name")]
98 pub fn icon_name(&self) -> Option<glib::GString> {
99 unsafe { from_glib_none(ffi::gtk_menu_button_get_icon_name(self.to_glib_none().0)) }
100 }
101
102 #[doc(alias = "gtk_menu_button_get_label")]
103 #[doc(alias = "get_label")]
104 pub fn label(&self) -> Option<glib::GString> {
105 unsafe { from_glib_none(ffi::gtk_menu_button_get_label(self.to_glib_none().0)) }
106 }
107
108 #[doc(alias = "gtk_menu_button_get_menu_model")]
109 #[doc(alias = "get_menu_model")]
110 #[doc(alias = "menu-model")]
111 pub fn menu_model(&self) -> Option<gio::MenuModel> {
112 unsafe { from_glib_none(ffi::gtk_menu_button_get_menu_model(self.to_glib_none().0)) }
113 }
114
115 #[doc(alias = "gtk_menu_button_get_popover")]
116 #[doc(alias = "get_popover")]
117 pub fn popover(&self) -> Option<Popover> {
118 unsafe { from_glib_none(ffi::gtk_menu_button_get_popover(self.to_glib_none().0)) }
119 }
120
121 #[cfg(feature = "v4_4")]
122 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
123 #[doc(alias = "gtk_menu_button_get_primary")]
124 #[doc(alias = "get_primary")]
125 #[doc(alias = "primary")]
126 pub fn is_primary(&self) -> bool {
127 unsafe { from_glib(ffi::gtk_menu_button_get_primary(self.to_glib_none().0)) }
128 }
129
130 #[doc(alias = "gtk_menu_button_get_use_underline")]
131 #[doc(alias = "get_use_underline")]
132 #[doc(alias = "use-underline")]
133 pub fn uses_underline(&self) -> bool {
134 unsafe {
135 from_glib(ffi::gtk_menu_button_get_use_underline(
136 self.to_glib_none().0,
137 ))
138 }
139 }
140
141 #[doc(alias = "gtk_menu_button_popdown")]
142 pub fn popdown(&self) {
143 unsafe {
144 ffi::gtk_menu_button_popdown(self.to_glib_none().0);
145 }
146 }
147
148 #[doc(alias = "gtk_menu_button_popup")]
149 pub fn popup(&self) {
150 unsafe {
151 ffi::gtk_menu_button_popup(self.to_glib_none().0);
152 }
153 }
154
155 #[cfg(feature = "v4_10")]
156 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
157 #[doc(alias = "gtk_menu_button_set_active")]
158 #[doc(alias = "active")]
159 pub fn set_active(&self, active: bool) {
160 unsafe {
161 ffi::gtk_menu_button_set_active(self.to_glib_none().0, active.into_glib());
162 }
163 }
164
165 #[cfg(feature = "v4_4")]
166 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
167 #[doc(alias = "gtk_menu_button_set_always_show_arrow")]
168 #[doc(alias = "always-show-arrow")]
169 pub fn set_always_show_arrow(&self, always_show_arrow: bool) {
170 unsafe {
171 ffi::gtk_menu_button_set_always_show_arrow(
172 self.to_glib_none().0,
173 always_show_arrow.into_glib(),
174 );
175 }
176 }
177
178 #[cfg(feature = "v4_12")]
179 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
180 #[doc(alias = "gtk_menu_button_set_can_shrink")]
181 #[doc(alias = "can-shrink")]
182 pub fn set_can_shrink(&self, can_shrink: bool) {
183 unsafe {
184 ffi::gtk_menu_button_set_can_shrink(self.to_glib_none().0, can_shrink.into_glib());
185 }
186 }
187
188 #[cfg(feature = "v4_6")]
189 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
190 #[doc(alias = "gtk_menu_button_set_child")]
191 #[doc(alias = "child")]
192 pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
193 unsafe {
194 ffi::gtk_menu_button_set_child(
195 self.to_glib_none().0,
196 child.map(|p| p.as_ref()).to_glib_none().0,
197 );
198 }
199 }
200
201 #[doc(alias = "gtk_menu_button_set_create_popup_func")]
202 pub fn set_create_popup_func<P: Fn(&MenuButton) + 'static>(&self, func: P) {
203 let func_data: Box_<P> = Box_::new(func);
204 unsafe extern "C" fn func_func<P: Fn(&MenuButton) + 'static>(
205 menu_button: *mut ffi::GtkMenuButton,
206 user_data: glib::ffi::gpointer,
207 ) {
208 let menu_button = from_glib_borrow(menu_button);
209 let callback = &*(user_data as *mut P);
210 (*callback)(&menu_button)
211 }
212 let func = Some(func_func::<P> as _);
213 unsafe extern "C" fn destroy_notify_func<P: Fn(&MenuButton) + 'static>(
214 data: glib::ffi::gpointer,
215 ) {
216 let _callback = Box_::from_raw(data as *mut P);
217 }
218 let destroy_call3 = Some(destroy_notify_func::<P> as _);
219 let super_callback0: Box_<P> = func_data;
220 unsafe {
221 ffi::gtk_menu_button_set_create_popup_func(
222 self.to_glib_none().0,
223 func,
224 Box_::into_raw(super_callback0) as *mut _,
225 destroy_call3,
226 );
227 }
228 }
229
230 #[doc(alias = "gtk_menu_button_set_direction")]
231 #[doc(alias = "direction")]
232 pub fn set_direction(&self, direction: ArrowType) {
233 unsafe {
234 ffi::gtk_menu_button_set_direction(self.to_glib_none().0, direction.into_glib());
235 }
236 }
237
238 #[doc(alias = "gtk_menu_button_set_has_frame")]
239 #[doc(alias = "has-frame")]
240 pub fn set_has_frame(&self, has_frame: bool) {
241 unsafe {
242 ffi::gtk_menu_button_set_has_frame(self.to_glib_none().0, has_frame.into_glib());
243 }
244 }
245
246 #[doc(alias = "gtk_menu_button_set_icon_name")]
247 #[doc(alias = "icon-name")]
248 pub fn set_icon_name(&self, icon_name: &str) {
249 unsafe {
250 ffi::gtk_menu_button_set_icon_name(self.to_glib_none().0, icon_name.to_glib_none().0);
251 }
252 }
253
254 #[doc(alias = "gtk_menu_button_set_label")]
255 #[doc(alias = "label")]
256 pub fn set_label(&self, label: &str) {
257 unsafe {
258 ffi::gtk_menu_button_set_label(self.to_glib_none().0, label.to_glib_none().0);
259 }
260 }
261
262 #[doc(alias = "gtk_menu_button_set_menu_model")]
263 #[doc(alias = "menu-model")]
264 pub fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
265 unsafe {
266 ffi::gtk_menu_button_set_menu_model(
267 self.to_glib_none().0,
268 menu_model.map(|p| p.as_ref()).to_glib_none().0,
269 );
270 }
271 }
272
273 #[doc(alias = "gtk_menu_button_set_popover")]
274 #[doc(alias = "popover")]
275 pub fn set_popover(&self, popover: Option<&impl IsA<Popover>>) {
276 unsafe {
277 ffi::gtk_menu_button_set_popover(
278 self.to_glib_none().0,
279 popover.map(|p| p.as_ref()).to_glib_none().0,
280 );
281 }
282 }
283
284 #[cfg(feature = "v4_4")]
285 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
286 #[doc(alias = "gtk_menu_button_set_primary")]
287 #[doc(alias = "primary")]
288 pub fn set_primary(&self, primary: bool) {
289 unsafe {
290 ffi::gtk_menu_button_set_primary(self.to_glib_none().0, primary.into_glib());
291 }
292 }
293
294 #[doc(alias = "gtk_menu_button_set_use_underline")]
295 #[doc(alias = "use-underline")]
296 pub fn set_use_underline(&self, use_underline: bool) {
297 unsafe {
298 ffi::gtk_menu_button_set_use_underline(
299 self.to_glib_none().0,
300 use_underline.into_glib(),
301 );
302 }
303 }
304
305 #[cfg(feature = "v4_4")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
307 #[doc(alias = "activate")]
308 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
309 unsafe extern "C" fn activate_trampoline<F: Fn(&MenuButton) + 'static>(
310 this: *mut ffi::GtkMenuButton,
311 f: glib::ffi::gpointer,
312 ) {
313 let f: &F = &*(f as *const F);
314 f(&from_glib_borrow(this))
315 }
316 unsafe {
317 let f: Box_<F> = Box_::new(f);
318 connect_raw(
319 self.as_ptr() as *mut _,
320 c"activate".as_ptr() as *const _,
321 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322 activate_trampoline::<F> as *const (),
323 )),
324 Box_::into_raw(f),
325 )
326 }
327 }
328
329 #[cfg(feature = "v4_4")]
330 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
331 pub fn emit_activate(&self) {
332 self.emit_by_name::<()>("activate", &[]);
333 }
334
335 #[cfg(feature = "v4_10")]
336 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
337 #[doc(alias = "active")]
338 pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
339 unsafe extern "C" fn notify_active_trampoline<F: Fn(&MenuButton) + 'static>(
340 this: *mut ffi::GtkMenuButton,
341 _param_spec: glib::ffi::gpointer,
342 f: glib::ffi::gpointer,
343 ) {
344 let f: &F = &*(f as *const F);
345 f(&from_glib_borrow(this))
346 }
347 unsafe {
348 let f: Box_<F> = Box_::new(f);
349 connect_raw(
350 self.as_ptr() as *mut _,
351 c"notify::active".as_ptr() as *const _,
352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353 notify_active_trampoline::<F> as *const (),
354 )),
355 Box_::into_raw(f),
356 )
357 }
358 }
359
360 #[cfg(feature = "v4_4")]
361 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
362 #[doc(alias = "always-show-arrow")]
363 pub fn connect_always_show_arrow_notify<F: Fn(&Self) + 'static>(
364 &self,
365 f: F,
366 ) -> SignalHandlerId {
367 unsafe extern "C" fn notify_always_show_arrow_trampoline<F: Fn(&MenuButton) + 'static>(
368 this: *mut ffi::GtkMenuButton,
369 _param_spec: glib::ffi::gpointer,
370 f: glib::ffi::gpointer,
371 ) {
372 let f: &F = &*(f as *const F);
373 f(&from_glib_borrow(this))
374 }
375 unsafe {
376 let f: Box_<F> = Box_::new(f);
377 connect_raw(
378 self.as_ptr() as *mut _,
379 c"notify::always-show-arrow".as_ptr() as *const _,
380 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
381 notify_always_show_arrow_trampoline::<F> as *const (),
382 )),
383 Box_::into_raw(f),
384 )
385 }
386 }
387
388 #[cfg(feature = "v4_12")]
389 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
390 #[doc(alias = "can-shrink")]
391 pub fn connect_can_shrink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
392 unsafe extern "C" fn notify_can_shrink_trampoline<F: Fn(&MenuButton) + 'static>(
393 this: *mut ffi::GtkMenuButton,
394 _param_spec: glib::ffi::gpointer,
395 f: glib::ffi::gpointer,
396 ) {
397 let f: &F = &*(f as *const F);
398 f(&from_glib_borrow(this))
399 }
400 unsafe {
401 let f: Box_<F> = Box_::new(f);
402 connect_raw(
403 self.as_ptr() as *mut _,
404 c"notify::can-shrink".as_ptr() as *const _,
405 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
406 notify_can_shrink_trampoline::<F> as *const (),
407 )),
408 Box_::into_raw(f),
409 )
410 }
411 }
412
413 #[cfg(feature = "v4_6")]
414 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
415 #[doc(alias = "child")]
416 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
417 unsafe extern "C" fn notify_child_trampoline<F: Fn(&MenuButton) + 'static>(
418 this: *mut ffi::GtkMenuButton,
419 _param_spec: glib::ffi::gpointer,
420 f: glib::ffi::gpointer,
421 ) {
422 let f: &F = &*(f as *const F);
423 f(&from_glib_borrow(this))
424 }
425 unsafe {
426 let f: Box_<F> = Box_::new(f);
427 connect_raw(
428 self.as_ptr() as *mut _,
429 c"notify::child".as_ptr() as *const _,
430 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
431 notify_child_trampoline::<F> as *const (),
432 )),
433 Box_::into_raw(f),
434 )
435 }
436 }
437
438 #[doc(alias = "direction")]
439 pub fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
440 unsafe extern "C" fn notify_direction_trampoline<F: Fn(&MenuButton) + 'static>(
441 this: *mut ffi::GtkMenuButton,
442 _param_spec: glib::ffi::gpointer,
443 f: glib::ffi::gpointer,
444 ) {
445 let f: &F = &*(f as *const F);
446 f(&from_glib_borrow(this))
447 }
448 unsafe {
449 let f: Box_<F> = Box_::new(f);
450 connect_raw(
451 self.as_ptr() as *mut _,
452 c"notify::direction".as_ptr() as *const _,
453 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
454 notify_direction_trampoline::<F> as *const (),
455 )),
456 Box_::into_raw(f),
457 )
458 }
459 }
460
461 #[doc(alias = "has-frame")]
462 pub fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
463 unsafe extern "C" fn notify_has_frame_trampoline<F: Fn(&MenuButton) + 'static>(
464 this: *mut ffi::GtkMenuButton,
465 _param_spec: glib::ffi::gpointer,
466 f: glib::ffi::gpointer,
467 ) {
468 let f: &F = &*(f as *const F);
469 f(&from_glib_borrow(this))
470 }
471 unsafe {
472 let f: Box_<F> = Box_::new(f);
473 connect_raw(
474 self.as_ptr() as *mut _,
475 c"notify::has-frame".as_ptr() as *const _,
476 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
477 notify_has_frame_trampoline::<F> as *const (),
478 )),
479 Box_::into_raw(f),
480 )
481 }
482 }
483
484 #[doc(alias = "icon-name")]
485 pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
486 unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&MenuButton) + 'static>(
487 this: *mut ffi::GtkMenuButton,
488 _param_spec: glib::ffi::gpointer,
489 f: glib::ffi::gpointer,
490 ) {
491 let f: &F = &*(f as *const F);
492 f(&from_glib_borrow(this))
493 }
494 unsafe {
495 let f: Box_<F> = Box_::new(f);
496 connect_raw(
497 self.as_ptr() as *mut _,
498 c"notify::icon-name".as_ptr() as *const _,
499 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
500 notify_icon_name_trampoline::<F> as *const (),
501 )),
502 Box_::into_raw(f),
503 )
504 }
505 }
506
507 #[doc(alias = "label")]
508 pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
509 unsafe extern "C" fn notify_label_trampoline<F: Fn(&MenuButton) + 'static>(
510 this: *mut ffi::GtkMenuButton,
511 _param_spec: glib::ffi::gpointer,
512 f: glib::ffi::gpointer,
513 ) {
514 let f: &F = &*(f as *const F);
515 f(&from_glib_borrow(this))
516 }
517 unsafe {
518 let f: Box_<F> = Box_::new(f);
519 connect_raw(
520 self.as_ptr() as *mut _,
521 c"notify::label".as_ptr() as *const _,
522 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
523 notify_label_trampoline::<F> as *const (),
524 )),
525 Box_::into_raw(f),
526 )
527 }
528 }
529
530 #[doc(alias = "menu-model")]
531 pub fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
532 unsafe extern "C" fn notify_menu_model_trampoline<F: Fn(&MenuButton) + 'static>(
533 this: *mut ffi::GtkMenuButton,
534 _param_spec: glib::ffi::gpointer,
535 f: glib::ffi::gpointer,
536 ) {
537 let f: &F = &*(f as *const F);
538 f(&from_glib_borrow(this))
539 }
540 unsafe {
541 let f: Box_<F> = Box_::new(f);
542 connect_raw(
543 self.as_ptr() as *mut _,
544 c"notify::menu-model".as_ptr() as *const _,
545 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
546 notify_menu_model_trampoline::<F> as *const (),
547 )),
548 Box_::into_raw(f),
549 )
550 }
551 }
552
553 #[doc(alias = "popover")]
554 pub fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
555 unsafe extern "C" fn notify_popover_trampoline<F: Fn(&MenuButton) + 'static>(
556 this: *mut ffi::GtkMenuButton,
557 _param_spec: glib::ffi::gpointer,
558 f: glib::ffi::gpointer,
559 ) {
560 let f: &F = &*(f as *const F);
561 f(&from_glib_borrow(this))
562 }
563 unsafe {
564 let f: Box_<F> = Box_::new(f);
565 connect_raw(
566 self.as_ptr() as *mut _,
567 c"notify::popover".as_ptr() as *const _,
568 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
569 notify_popover_trampoline::<F> as *const (),
570 )),
571 Box_::into_raw(f),
572 )
573 }
574 }
575
576 #[cfg(feature = "v4_4")]
577 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
578 #[doc(alias = "primary")]
579 pub fn connect_primary_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
580 unsafe extern "C" fn notify_primary_trampoline<F: Fn(&MenuButton) + 'static>(
581 this: *mut ffi::GtkMenuButton,
582 _param_spec: glib::ffi::gpointer,
583 f: glib::ffi::gpointer,
584 ) {
585 let f: &F = &*(f as *const F);
586 f(&from_glib_borrow(this))
587 }
588 unsafe {
589 let f: Box_<F> = Box_::new(f);
590 connect_raw(
591 self.as_ptr() as *mut _,
592 c"notify::primary".as_ptr() as *const _,
593 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
594 notify_primary_trampoline::<F> as *const (),
595 )),
596 Box_::into_raw(f),
597 )
598 }
599 }
600
601 #[doc(alias = "use-underline")]
602 pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
603 unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&MenuButton) + 'static>(
604 this: *mut ffi::GtkMenuButton,
605 _param_spec: glib::ffi::gpointer,
606 f: glib::ffi::gpointer,
607 ) {
608 let f: &F = &*(f as *const F);
609 f(&from_glib_borrow(this))
610 }
611 unsafe {
612 let f: Box_<F> = Box_::new(f);
613 connect_raw(
614 self.as_ptr() as *mut _,
615 c"notify::use-underline".as_ptr() as *const _,
616 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
617 notify_use_underline_trampoline::<F> as *const (),
618 )),
619 Box_::into_raw(f),
620 )
621 }
622 }
623}
624
625impl Default for MenuButton {
626 fn default() -> Self {
627 Self::new()
628 }
629}
630
631#[must_use = "The builder must be built to be used"]
636pub struct MenuButtonBuilder {
637 builder: glib::object::ObjectBuilder<'static, MenuButton>,
638}
639
640impl MenuButtonBuilder {
641 fn new() -> Self {
642 Self {
643 builder: glib::object::Object::builder(),
644 }
645 }
646
647 #[cfg(feature = "v4_10")]
648 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
649 pub fn active(self, active: bool) -> Self {
650 Self {
651 builder: self.builder.property("active", active),
652 }
653 }
654
655 #[cfg(feature = "v4_4")]
656 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
657 pub fn always_show_arrow(self, always_show_arrow: bool) -> Self {
658 Self {
659 builder: self
660 .builder
661 .property("always-show-arrow", always_show_arrow),
662 }
663 }
664
665 #[cfg(feature = "v4_12")]
666 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
667 pub fn can_shrink(self, can_shrink: bool) -> Self {
668 Self {
669 builder: self.builder.property("can-shrink", can_shrink),
670 }
671 }
672
673 #[cfg(feature = "v4_6")]
674 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
675 pub fn child(self, child: &impl IsA<Widget>) -> Self {
676 Self {
677 builder: self.builder.property("child", child.clone().upcast()),
678 }
679 }
680
681 pub fn direction(self, direction: ArrowType) -> Self {
682 Self {
683 builder: self.builder.property("direction", direction),
684 }
685 }
686
687 pub fn has_frame(self, has_frame: bool) -> Self {
688 Self {
689 builder: self.builder.property("has-frame", has_frame),
690 }
691 }
692
693 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
694 Self {
695 builder: self.builder.property("icon-name", icon_name.into()),
696 }
697 }
698
699 pub fn label(self, label: impl Into<glib::GString>) -> Self {
700 Self {
701 builder: self.builder.property("label", label.into()),
702 }
703 }
704
705 pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
706 Self {
707 builder: self
708 .builder
709 .property("menu-model", menu_model.clone().upcast()),
710 }
711 }
712
713 pub fn popover(self, popover: &impl IsA<Popover>) -> Self {
714 Self {
715 builder: self.builder.property("popover", popover.clone().upcast()),
716 }
717 }
718
719 #[cfg(feature = "v4_4")]
720 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
721 pub fn primary(self, primary: bool) -> Self {
722 Self {
723 builder: self.builder.property("primary", primary),
724 }
725 }
726
727 pub fn use_underline(self, use_underline: bool) -> Self {
728 Self {
729 builder: self.builder.property("use-underline", use_underline),
730 }
731 }
732
733 pub fn can_focus(self, can_focus: bool) -> Self {
734 Self {
735 builder: self.builder.property("can-focus", can_focus),
736 }
737 }
738
739 pub fn can_target(self, can_target: bool) -> Self {
740 Self {
741 builder: self.builder.property("can-target", can_target),
742 }
743 }
744
745 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
746 Self {
747 builder: self.builder.property("css-classes", css_classes.into()),
748 }
749 }
750
751 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
752 Self {
753 builder: self.builder.property("css-name", css_name.into()),
754 }
755 }
756
757 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
758 Self {
759 builder: self.builder.property("cursor", cursor.clone()),
760 }
761 }
762
763 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
764 Self {
765 builder: self.builder.property("focus-on-click", focus_on_click),
766 }
767 }
768
769 pub fn focusable(self, focusable: bool) -> Self {
770 Self {
771 builder: self.builder.property("focusable", focusable),
772 }
773 }
774
775 pub fn halign(self, halign: Align) -> Self {
776 Self {
777 builder: self.builder.property("halign", halign),
778 }
779 }
780
781 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
782 Self {
783 builder: self.builder.property("has-tooltip", has_tooltip),
784 }
785 }
786
787 pub fn height_request(self, height_request: i32) -> Self {
788 Self {
789 builder: self.builder.property("height-request", height_request),
790 }
791 }
792
793 pub fn hexpand(self, hexpand: bool) -> Self {
794 Self {
795 builder: self.builder.property("hexpand", hexpand),
796 }
797 }
798
799 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
800 Self {
801 builder: self.builder.property("hexpand-set", hexpand_set),
802 }
803 }
804
805 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
806 Self {
807 builder: self
808 .builder
809 .property("layout-manager", layout_manager.clone().upcast()),
810 }
811 }
812
813 #[cfg(feature = "v4_18")]
814 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
815 pub fn limit_events(self, limit_events: bool) -> Self {
816 Self {
817 builder: self.builder.property("limit-events", limit_events),
818 }
819 }
820
821 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
822 Self {
823 builder: self.builder.property("margin-bottom", margin_bottom),
824 }
825 }
826
827 pub fn margin_end(self, margin_end: i32) -> Self {
828 Self {
829 builder: self.builder.property("margin-end", margin_end),
830 }
831 }
832
833 pub fn margin_start(self, margin_start: i32) -> Self {
834 Self {
835 builder: self.builder.property("margin-start", margin_start),
836 }
837 }
838
839 pub fn margin_top(self, margin_top: i32) -> Self {
840 Self {
841 builder: self.builder.property("margin-top", margin_top),
842 }
843 }
844
845 pub fn name(self, name: impl Into<glib::GString>) -> Self {
846 Self {
847 builder: self.builder.property("name", name.into()),
848 }
849 }
850
851 pub fn opacity(self, opacity: f64) -> Self {
852 Self {
853 builder: self.builder.property("opacity", opacity),
854 }
855 }
856
857 pub fn overflow(self, overflow: Overflow) -> Self {
858 Self {
859 builder: self.builder.property("overflow", overflow),
860 }
861 }
862
863 pub fn receives_default(self, receives_default: bool) -> Self {
864 Self {
865 builder: self.builder.property("receives-default", receives_default),
866 }
867 }
868
869 pub fn sensitive(self, sensitive: bool) -> Self {
870 Self {
871 builder: self.builder.property("sensitive", sensitive),
872 }
873 }
874
875 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
876 Self {
877 builder: self
878 .builder
879 .property("tooltip-markup", tooltip_markup.into()),
880 }
881 }
882
883 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
884 Self {
885 builder: self.builder.property("tooltip-text", tooltip_text.into()),
886 }
887 }
888
889 pub fn valign(self, valign: Align) -> Self {
890 Self {
891 builder: self.builder.property("valign", valign),
892 }
893 }
894
895 pub fn vexpand(self, vexpand: bool) -> Self {
896 Self {
897 builder: self.builder.property("vexpand", vexpand),
898 }
899 }
900
901 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
902 Self {
903 builder: self.builder.property("vexpand-set", vexpand_set),
904 }
905 }
906
907 pub fn visible(self, visible: bool) -> Self {
908 Self {
909 builder: self.builder.property("visible", visible),
910 }
911 }
912
913 pub fn width_request(self, width_request: i32) -> Self {
914 Self {
915 builder: self.builder.property("width-request", width_request),
916 }
917 }
918
919 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
920 Self {
921 builder: self.builder.property("accessible-role", accessible_role),
922 }
923 }
924
925 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
928 pub fn build(self) -> MenuButton {
929 assert_initialized_main_thread!();
930 self.builder.build()
931 }
932}