[]Struct gio::Menu

pub struct Menu(_, _);

Menu is a simple implementation of MenuModel. You populate a Menu by adding MenuItem instances to it.

There are some convenience functions to allow you to directly add items (avoiding MenuItem) for the common cases. To add a regular item, use Menu::insert. To add a section, use Menu::insert_section. To add a submenu, use Menu::insert_submenu.

Implements

MenuModelExt, glib::object::ObjectExt

Methods

impl Menu[src]

pub fn new() -> Menu[src]

Creates a new Menu.

The new menu has no items.

Returns

a new Menu

pub fn append(&self, label: Option<&str>, detailed_action: Option<&str>)[src]

Convenience function for appending a normal menu item to the end of self. Combine MenuItem::new and Menu::insert_item for a more flexible alternative.

label

the section label, or None

detailed_action

the detailed action string, or None

pub fn append_item(&self, item: &MenuItem)[src]

Appends item to the end of self.

See Menu::insert_item for more information.

item

a MenuItem to append

pub fn append_section<P: IsA<MenuModel>>(
    &self,
    label: Option<&str>,
    section: &P
)
[src]

Convenience function for appending a section menu item to the end of self. Combine MenuItem::new_section and Menu::insert_item for a more flexible alternative.

label

the section label, or None

section

a MenuModel with the items of the section

pub fn append_submenu<P: IsA<MenuModel>>(
    &self,
    label: Option<&str>,
    submenu: &P
)
[src]

Convenience function for appending a submenu menu item to the end of self. Combine MenuItem::new_submenu and Menu::insert_item for a more flexible alternative.

label

the section label, or None

a MenuModel with the items of the submenu

pub fn freeze(&self)[src]

Marks self as frozen.

After the menu is frozen, it is an error to attempt to make any changes to it. In effect this means that the Menu API must no longer be used.

This function causes MenuModelExt::is_mutable to begin returning false, which has some positive performance implications.

pub fn insert(
    &self,
    position: i32,
    label: Option<&str>,
    detailed_action: Option<&str>
)
[src]

Convenience function for inserting a normal menu item into self. Combine MenuItem::new and Menu::insert_item for a more flexible alternative.

position

the position at which to insert the item

label

the section label, or None

detailed_action

the detailed action string, or None

pub fn insert_item(&self, position: i32, item: &MenuItem)[src]

Inserts item into self.

The "insertion" is actually done by copying all of the attribute and link values of item and using them to form a new item within self. As such, item itself is not really inserted, but rather, a menu item that is exactly the same as the one presently described by item.

This means that item is essentially useless after the insertion occurs. Any changes you make to it are ignored unless it is inserted again (at which point its updated values will be copied).

You should probably just free item once you're done.

There are many convenience functions to take care of common cases. See Menu::insert, Menu::insert_section and Menu::insert_submenu as well as "prepend" and "append" variants of each of these functions.

position

the position at which to insert the item

item

the MenuItem to insert

pub fn insert_section<P: IsA<MenuModel>>(
    &self,
    position: i32,
    label: Option<&str>,
    section: &P
)
[src]

Convenience function for inserting a section menu item into self. Combine MenuItem::new_section and Menu::insert_item for a more flexible alternative.

position

the position at which to insert the item

label

the section label, or None

section

a MenuModel with the items of the section

pub fn insert_submenu<P: IsA<MenuModel>>(
    &self,
    position: i32,
    label: Option<&str>,
    submenu: &P
)
[src]

Convenience function for inserting a submenu menu item into self. Combine MenuItem::new_submenu and Menu::insert_item for a more flexible alternative.

position

the position at which to insert the item

label

the section label, or None

a MenuModel with the items of the submenu

pub fn prepend(&self, label: Option<&str>, detailed_action: Option<&str>)[src]

Convenience function for prepending a normal menu item to the start of self. Combine MenuItem::new and Menu::insert_item for a more flexible alternative.

label

the section label, or None

detailed_action

the detailed action string, or None

pub fn prepend_item(&self, item: &MenuItem)[src]

Prepends item to the start of self.

See Menu::insert_item for more information.

item

a MenuItem to prepend

pub fn prepend_section<P: IsA<MenuModel>>(
    &self,
    label: Option<&str>,
    section: &P
)
[src]

Convenience function for prepending a section menu item to the start of self. Combine MenuItem::new_section and Menu::insert_item for a more flexible alternative.

label

the section label, or None

section

a MenuModel with the items of the section

pub fn prepend_submenu<P: IsA<MenuModel>>(
    &self,
    label: Option<&str>,
    submenu: &P
)
[src]

Convenience function for prepending a submenu menu item to the start of self. Combine MenuItem::new_submenu and Menu::insert_item for a more flexible alternative.

label

the section label, or None

a MenuModel with the items of the submenu

pub fn remove(&self, position: i32)[src]

Removes an item from the menu.

position gives the index of the item to remove.

It is an error if position is not in range the range from 0 to one less than the number of items in the menu.

It is not possible to remove items by identity since items are added to the menu simply by copying their links and attributes (ie: identity of the item itself is not preserved).

position

the position of the item to remove

pub fn remove_all(&self)[src]

Removes all items in the menu.

Trait Implementations

impl Clone for Menu

impl Debug for Menu

impl Default for Menu[src]

impl Display for Menu[src]

impl Eq for Menu

impl Hash for Menu

impl IsA<MenuModel> for Menu

impl Ord for Menu

impl<T: ObjectType> PartialEq<T> for Menu

impl<T: ObjectType> PartialOrd<T> for Menu

impl StaticType for Menu

Auto Trait Implementations

impl RefUnwindSafe for Menu

impl !Send for Menu

impl !Sync for Menu

impl Unpin for Menu

impl UnwindSafe for Menu

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 
[src]

impl<T> Cast for T where
    T: ObjectType
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.