1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::Buildable;
use crate::Container;
use crate::DirectionType;
use crate::MenuDirectionType;
use crate::MenuItem;
use crate::Widget;
use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectExt;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
/// A [`MenuShell`][crate::MenuShell] is the abstract base class used to derive the
/// [`Menu`][crate::Menu] and [`MenuBar`][crate::MenuBar] subclasses.
///
/// A [`MenuShell`][crate::MenuShell] is a container of [`MenuItem`][crate::MenuItem] objects arranged
/// in a list which can be navigated, selected, and activated by the
/// user to perform application functions. A [`MenuItem`][crate::MenuItem] can have a
/// submenu associated with it, allowing for nested hierarchical menus.
///
/// # Terminology
///
/// A menu item can be “selected”, this means that it is displayed
/// in the prelight state, and if it has a submenu, that submenu
/// will be popped up.
///
/// A menu is “active” when it is visible onscreen and the user
/// is selecting from it. A menubar is not active until the user
/// clicks on one of its menuitems. When a menu is active,
/// passing the mouse over a submenu will pop it up.
///
/// There is also is a concept of the current menu and a current
/// menu item. The current menu item is the selected menu item
/// that is furthest down in the hierarchy. (Every active menu shell
/// does not necessarily contain a selected menu item, but if
/// it does, then the parent menu shell must also contain
/// a selected menu item.) The current menu is the menu that
/// contains the current menu item. It will always have a GTK
/// grab and receive all key presses.
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// # Implements
///
/// [`MenuShellExt`][trait@crate::prelude::MenuShellExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
#[doc(alias = "GtkMenuShell")]
pub struct MenuShell(Object<ffi::GtkMenuShell, ffi::GtkMenuShellClass>) @extends Container, Widget, @implements Buildable;
match fn {
type_ => || ffi::gtk_menu_shell_get_type(),
}
}
impl MenuShell {
pub const NONE: Option<&'static MenuShell> = None;
}
/// Trait containing all [`struct@MenuShell`] methods.
///
/// # Implementors
///
/// [`MenuBar`][struct@crate::MenuBar], [`MenuShell`][struct@crate::MenuShell], [`Menu`][struct@crate::Menu]
pub trait MenuShellExt: 'static {
/// Activates the menu item within the menu shell.
/// ## `menu_item`
/// the [`MenuItem`][crate::MenuItem] to activate
/// ## `force_deactivate`
/// if [`true`], force the deactivation of the
/// menu shell after the menu item is activated
#[doc(alias = "gtk_menu_shell_activate_item")]
fn activate_item(&self, menu_item: &impl IsA<Widget>, force_deactivate: bool);
/// Adds a new [`MenuItem`][crate::MenuItem] to the end of the menu shell's
/// item list.
/// ## `child`
/// The [`MenuItem`][crate::MenuItem] to add
#[doc(alias = "gtk_menu_shell_append")]
fn append(&self, child: &impl IsA<MenuItem>);
/// Establishes a binding between a [`MenuShell`][crate::MenuShell] and a [`gio::MenuModel`][crate::gio::MenuModel].
///
/// The contents of `shell` are removed and then refilled with menu items
/// according to `model`. When `model` changes, `shell` is updated.
/// Calling this function twice on `shell` with different `model` will
/// cause the first binding to be replaced with a binding to the new
/// model. If `model` is [`None`] then any previous binding is undone and
/// all children are removed.
///
/// `with_separators` determines if toplevel items (eg: sections) have
/// separators inserted between them. This is typically desired for
/// menus but doesn’t make sense for menubars.
///
/// If `action_namespace` is non-[`None`] then the effect is as if all
/// actions mentioned in the `model` have their names prefixed with the
/// namespace, plus a dot. For example, if the action “quit” is
/// mentioned and `action_namespace` is “app” then the effective action
/// name is “app.quit”.
///
/// This function uses [`Actionable`][crate::Actionable] to define the action name and
/// target values on the created menu items. If you want to use an
/// action group other than “app” and “win”, or if you want to use a
/// [`MenuShell`][crate::MenuShell] outside of a [`ApplicationWindow`][crate::ApplicationWindow], then you will need
/// to attach your own action group to the widget hierarchy using
/// [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()]. As an example, if you created a
/// group with a “quit” action and inserted it with the name “mygroup”
/// then you would use the action name “mygroup.quit” in your
/// [`gio::MenuModel`][crate::gio::MenuModel].
///
/// For most cases you are probably better off using
/// [`Menu::from_model()`][crate::Menu::from_model()] or [`MenuBar::from_model()`][crate::MenuBar::from_model()] or just
/// directly passing the [`gio::MenuModel`][crate::gio::MenuModel] to [`GtkApplicationExt::set_app_menu()`][crate::prelude::GtkApplicationExt::set_app_menu()] or
/// [`GtkApplicationExt::set_menubar()`][crate::prelude::GtkApplicationExt::set_menubar()].
/// ## `model`
/// the [`gio::MenuModel`][crate::gio::MenuModel] to bind to or [`None`] to remove
/// binding
/// ## `action_namespace`
/// the namespace for actions in `model`
/// ## `with_separators`
/// [`true`] if toplevel items in `shell` should have
/// separators between them
#[doc(alias = "gtk_menu_shell_bind_model")]
fn bind_model(
&self,
model: Option<&impl IsA<gio::MenuModel>>,
action_namespace: Option<&str>,
with_separators: bool,
);
/// Cancels the selection within the menu shell.
#[doc(alias = "gtk_menu_shell_cancel")]
fn cancel(&self);
/// Deactivates the menu shell.
///
/// Typically this results in the menu shell being erased
/// from the screen.
#[doc(alias = "gtk_menu_shell_deactivate")]
fn deactivate(&self);
/// Deselects the currently selected item from the menu shell,
/// if any.
#[doc(alias = "gtk_menu_shell_deselect")]
fn deselect(&self);
/// Gets the parent menu shell.
///
/// The parent menu shell of a submenu is the [`Menu`][crate::Menu] or [`MenuBar`][crate::MenuBar]
/// from which it was opened up.
///
/// # Returns
///
/// the parent [`MenuShell`][crate::MenuShell]
#[doc(alias = "gtk_menu_shell_get_parent_shell")]
#[doc(alias = "get_parent_shell")]
fn parent_shell(&self) -> Option<Widget>;
/// Gets the currently selected item.
///
/// # Returns
///
/// the currently selected item
#[doc(alias = "gtk_menu_shell_get_selected_item")]
#[doc(alias = "get_selected_item")]
fn selected_item(&self) -> Option<Widget>;
/// Returns [`true`] if the menu shell will take the keyboard focus on popup.
///
/// # Returns
///
/// [`true`] if the menu shell will take the keyboard focus on popup.
#[doc(alias = "gtk_menu_shell_get_take_focus")]
#[doc(alias = "get_take_focus")]
fn takes_focus(&self) -> bool;
/// Adds a new [`MenuItem`][crate::MenuItem] to the menu shell’s item list
/// at the position indicated by `position`.
/// ## `child`
/// The [`MenuItem`][crate::MenuItem] to add
/// ## `position`
/// The position in the item list where `child`
/// is added. Positions are numbered from 0 to n-1
#[doc(alias = "gtk_menu_shell_insert")]
fn insert(&self, child: &impl IsA<Widget>, position: i32);
/// Adds a new [`MenuItem`][crate::MenuItem] to the beginning of the menu shell's
/// item list.
/// ## `child`
/// The [`MenuItem`][crate::MenuItem] to add
#[doc(alias = "gtk_menu_shell_prepend")]
fn prepend(&self, child: &impl IsA<Widget>);
/// Select the first visible or selectable child of the menu shell;
/// don’t select tearoff items unless the only item is a tearoff
/// item.
/// ## `search_sensitive`
/// if [`true`], search for the first selectable
/// menu item, otherwise select nothing if
/// the first item isn’t sensitive. This
/// should be [`false`] if the menu is being
/// popped up initially.
#[doc(alias = "gtk_menu_shell_select_first")]
fn select_first(&self, search_sensitive: bool);
/// Selects the menu item from the menu shell.
/// ## `menu_item`
/// The [`MenuItem`][crate::MenuItem] to select
#[doc(alias = "gtk_menu_shell_select_item")]
fn select_item(&self, menu_item: &impl IsA<Widget>);
/// If `take_focus` is [`true`] (the default) the menu shell will take
/// the keyboard focus so that it will receive all keyboard events
/// which is needed to enable keyboard navigation in menus.
///
/// Setting `take_focus` to [`false`] is useful only for special applications
/// like virtual keyboard implementations which should not take keyboard
/// focus.
///
/// The `take_focus` state of a menu or menu bar is automatically
/// propagated to submenus whenever a submenu is popped up, so you
/// don’t have to worry about recursively setting it for your entire
/// menu hierarchy. Only when programmatically picking a submenu and
/// popping it up manually, the `take_focus` property of the submenu
/// needs to be set explicitly.
///
/// Note that setting it to [`false`] has side-effects:
///
/// If the focus is in some other app, it keeps the focus and keynav in
/// the menu doesn’t work. Consequently, keynav on the menu will only
/// work if the focus is on some toplevel owned by the onscreen keyboard.
///
/// To avoid confusing the user, menus with `take_focus` set to [`false`]
/// should not display mnemonics or accelerators, since it cannot be
/// guaranteed that they will work.
///
/// See also `gdk_keyboard_grab()`
/// ## `take_focus`
/// [`true`] if the menu shell should take the keyboard
/// focus on popup
#[doc(alias = "gtk_menu_shell_set_take_focus")]
fn set_take_focus(&self, take_focus: bool);
/// An action signal that activates the current menu item within
/// the menu shell.
/// ## `force_hide`
/// if [`true`], hide the menu after activating the menu item
#[doc(alias = "activate-current")]
fn connect_activate_current<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId;
fn emit_activate_current(&self, force_hide: bool);
/// An action signal which cancels the selection within the menu shell.
/// Causes the `signal::MenuShell::selection-done` signal to be emitted.
#[doc(alias = "cancel")]
fn connect_cancel<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn emit_cancel(&self);
/// A keybinding signal which moves the focus in the
/// given `direction`.
/// ## `direction`
/// the direction to cycle in
#[doc(alias = "cycle-focus")]
fn connect_cycle_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId;
fn emit_cycle_focus(&self, direction: DirectionType);
/// This signal is emitted when a menu shell is deactivated.
#[doc(alias = "deactivate")]
fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// The ::insert signal is emitted when a new [`MenuItem`][crate::MenuItem] is added to
/// a [`MenuShell`][crate::MenuShell]. A separate signal is used instead of
/// GtkContainer::add because of the need for an additional position
/// parameter.
///
/// The inverse of this signal is the GtkContainer::removed signal.
/// ## `child`
/// the [`MenuItem`][crate::MenuItem] that is being inserted
/// ## `position`
/// the position at which the insert occurs
#[doc(alias = "insert")]
fn connect_insert<F: Fn(&Self, &Widget, i32) + 'static>(&self, f: F) -> SignalHandlerId;
/// An keybinding signal which moves the current menu item
/// in the direction specified by `direction`.
/// ## `direction`
/// the direction to move
#[doc(alias = "move-current")]
fn connect_move_current<F: Fn(&Self, MenuDirectionType) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn emit_move_current(&self, direction: MenuDirectionType);
/// The ::move-selected signal is emitted to move the selection to
/// another item.
/// ## `distance`
/// +1 to move to the next item, -1 to move to the previous
///
/// # Returns
///
/// [`true`] to stop the signal emission, [`false`] to continue
#[doc(alias = "move-selected")]
fn connect_move_selected<F: Fn(&Self, i32) -> glib::signal::Inhibit + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// This signal is emitted when a selection has been
/// completed within a menu shell.
#[doc(alias = "selection-done")]
fn connect_selection_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "take-focus")]
fn connect_take_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<MenuShell>> MenuShellExt for O {
fn activate_item(&self, menu_item: &impl IsA<Widget>, force_deactivate: bool) {
unsafe {
ffi::gtk_menu_shell_activate_item(
self.as_ref().to_glib_none().0,
menu_item.as_ref().to_glib_none().0,
force_deactivate.into_glib(),
);
}
}
fn append(&self, child: &impl IsA<MenuItem>) {
unsafe {
ffi::gtk_menu_shell_append(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
);
}
}
fn bind_model(
&self,
model: Option<&impl IsA<gio::MenuModel>>,
action_namespace: Option<&str>,
with_separators: bool,
) {
unsafe {
ffi::gtk_menu_shell_bind_model(
self.as_ref().to_glib_none().0,
model.map(|p| p.as_ref()).to_glib_none().0,
action_namespace.to_glib_none().0,
with_separators.into_glib(),
);
}
}
fn cancel(&self) {
unsafe {
ffi::gtk_menu_shell_cancel(self.as_ref().to_glib_none().0);
}
}
fn deactivate(&self) {
unsafe {
ffi::gtk_menu_shell_deactivate(self.as_ref().to_glib_none().0);
}
}
fn deselect(&self) {
unsafe {
ffi::gtk_menu_shell_deselect(self.as_ref().to_glib_none().0);
}
}
fn parent_shell(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_menu_shell_get_parent_shell(
self.as_ref().to_glib_none().0,
))
}
}
fn selected_item(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_menu_shell_get_selected_item(
self.as_ref().to_glib_none().0,
))
}
}
fn takes_focus(&self) -> bool {
unsafe {
from_glib(ffi::gtk_menu_shell_get_take_focus(
self.as_ref().to_glib_none().0,
))
}
}
fn insert(&self, child: &impl IsA<Widget>, position: i32) {
unsafe {
ffi::gtk_menu_shell_insert(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
position,
);
}
}
fn prepend(&self, child: &impl IsA<Widget>) {
unsafe {
ffi::gtk_menu_shell_prepend(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
);
}
}
fn select_first(&self, search_sensitive: bool) {
unsafe {
ffi::gtk_menu_shell_select_first(
self.as_ref().to_glib_none().0,
search_sensitive.into_glib(),
);
}
}
fn select_item(&self, menu_item: &impl IsA<Widget>) {
unsafe {
ffi::gtk_menu_shell_select_item(
self.as_ref().to_glib_none().0,
menu_item.as_ref().to_glib_none().0,
);
}
}
fn set_take_focus(&self, take_focus: bool) {
unsafe {
ffi::gtk_menu_shell_set_take_focus(
self.as_ref().to_glib_none().0,
take_focus.into_glib(),
);
}
}
fn connect_activate_current<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn activate_current_trampoline<
P: IsA<MenuShell>,
F: Fn(&P, bool) + 'static,
>(
this: *mut ffi::GtkMenuShell,
force_hide: glib::ffi::gboolean,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(force_hide),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"activate-current\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
activate_current_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_activate_current(&self, force_hide: bool) {
self.emit_by_name::<()>("activate-current", &[&force_hide]);
}
fn connect_cancel<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn cancel_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkMenuShell,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"cancel\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
cancel_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_cancel(&self) {
self.emit_by_name::<()>("cancel", &[]);
}
fn connect_cycle_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn cycle_focus_trampoline<
P: IsA<MenuShell>,
F: Fn(&P, DirectionType) + 'static,
>(
this: *mut ffi::GtkMenuShell,
direction: ffi::GtkDirectionType,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(direction),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"cycle-focus\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
cycle_focus_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_cycle_focus(&self, direction: DirectionType) {
self.emit_by_name::<()>("cycle-focus", &[&direction]);
}
fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn deactivate_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkMenuShell,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"deactivate\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
deactivate_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_insert<F: Fn(&Self, &Widget, i32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn insert_trampoline<
P: IsA<MenuShell>,
F: Fn(&P, &Widget, i32) + 'static,
>(
this: *mut ffi::GtkMenuShell,
child: *mut ffi::GtkWidget,
position: libc::c_int,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(child),
position,
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"insert\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
insert_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_move_current<F: Fn(&Self, MenuDirectionType) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn move_current_trampoline<
P: IsA<MenuShell>,
F: Fn(&P, MenuDirectionType) + 'static,
>(
this: *mut ffi::GtkMenuShell,
direction: ffi::GtkMenuDirectionType,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(direction),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"move-current\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
move_current_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_move_current(&self, direction: MenuDirectionType) {
self.emit_by_name::<()>("move-current", &[&direction]);
}
fn connect_move_selected<F: Fn(&Self, i32) -> glib::signal::Inhibit + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn move_selected_trampoline<
P: IsA<MenuShell>,
F: Fn(&P, i32) -> glib::signal::Inhibit + 'static,
>(
this: *mut ffi::GtkMenuShell,
distance: libc::c_int,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
distance,
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"move-selected\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
move_selected_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_selection_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn selection_done_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkMenuShell,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"selection-done\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
selection_done_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_take_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_take_focus_trampoline<
P: IsA<MenuShell>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkMenuShell,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::take-focus\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_take_focus_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for MenuShell {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("MenuShell")
}
}