Struct gio::Menu [−][src]
pub struct Menu(_);
Expand description
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 insert()
. To add a section, use
insert_section()
. To add a submenu, use
insert_submenu()
.
Implements
Implementations
Convenience function for appending a normal menu item to the end of
self
. Combine MenuItem::new()
and insert_item()
for a more
flexible alternative.
label
the section label, or None
detailed_action
the detailed action string, or None
Convenience function for appending a section menu item to the end of
self
. Combine MenuItem::new_section()
and insert_item()
for a
more flexible alternative.
label
the section label, or None
section
a MenuModel
with the items of the section
Convenience function for appending a submenu menu item to the end of
self
. Combine MenuItem::new_submenu()
and insert_item()
for a
more flexible alternative.
label
the section label, or None
submenu
a MenuModel
with the items of the submenu
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.
Convenience function for inserting a normal menu item into self
.
Combine MenuItem::new()
and 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
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 insert()
, insert_section()
and
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
Convenience function for inserting a section menu item into self
.
Combine MenuItem::new_section()
and 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
Convenience function for inserting a submenu menu item into self
.
Combine MenuItem::new_submenu()
and insert_item()
for a more
flexible alternative.
position
the position at which to insert the item
label
the section label, or None
submenu
a MenuModel
with the items of the submenu
Convenience function for prepending a normal menu item to the start
of self
. Combine MenuItem::new()
and insert_item()
for a more
flexible alternative.
label
the section label, or None
detailed_action
the detailed action string, or None
Prepends item
to the start of self
.
See insert_item()
for more information.
item
a MenuItem
to prepend
Convenience function for prepending a section menu item to the start
of self
. Combine MenuItem::new_section()
and insert_item()
for
a more flexible alternative.
label
the section label, or None
section
a MenuModel
with the items of the section
Convenience function for prepending a submenu menu item to the start
of self
. Combine MenuItem::new_submenu()
and insert_item()
for
a more flexible alternative.
label
the section label, or None
submenu
a MenuModel
with the items of the submenu
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
Removes all items in the menu.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Menu
impl UnwindSafe for Menu
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Emit signal with details by signal id.
Emit signal by it’s name.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,