Class: Gio::MenuModel
- Inherits:
-
Object
- Object
- Gio::MenuModel
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#get_item_attribute(item_index, attribute, format_string, array) ⇒ TrueClass
Queries item at position item_index in model for the attribute specified by attribute.
-
#get_item_attribute_value(item_index, attribute, expected_type) ⇒ GLib::Variant
Queries the item at position item_index in model for the attribute specified by attribute.
-
#get_item_link(item_index, link) ⇒ Gio::MenuModel
Queries the item at position item_index in model for the link specified by link.
-
#is_mutable ⇒ TrueClass
Queries if model is mutable.
-
#items_changed(position, removed, added) ⇒ nil
Requests emission of the GMenu::Model::items-changed signal on model.
-
#iterate_item_attributes(item_index) ⇒ Gio::MenuAttributeIter
Creates a GMenu::AttributeIter to iterate over the attributes of the item at position item_index in model.
-
#iterate_item_links(item_index) ⇒ Gio::MenuLinkIter
Creates a GMenu::LinkIter to iterate over the links of the item at position item_index in model.
-
#n_items ⇒ Integer
Query the number of items in model.
Instance Method Details
#get_item_attribute(item_index, attribute, format_string, array) ⇒ TrueClass
Queries item at position item_index in model for the attribute specified by attribute.
If the attribute exists and matches the GVariant::Type corresponding to format_string then format_string is used to deconstruct the value into the positional parameters and true is returned.
If the attribute does not exist, or it does exist but has the wrong type, then the positional parameters are ignored and false is returned.
This function is a mix of g_menu_model_get_item_attribute_value() and g_variant_get(), followed by a g_variant_unref(). As such, format_string must make a complete copy of the data (since the #GVariant may go away after the call to g_variant_unref()). In particular, no ‘&’ characters are allowed in format_string.
#get_item_attribute_value(item_index, attribute, expected_type) ⇒ GLib::Variant
Queries the item at position item_index in model for the attribute specified by attribute.
If expected_type is non-nil then it specifies the expected type of the attribute. If it is nil then any type will be accepted.
If the attribute exists and matches expected_type (or if the expected type is unspecified) then the value is returned.
If the attribute does not exist, or does not match the expected type then nil is returned.
#get_item_link(item_index, link) ⇒ Gio::MenuModel
Queries the item at position item_index in model for the link specified by link.
If the link exists, the linked GMenu::Model is returned. If the link does not exist, nil is returned.
#is_mutable ⇒ TrueClass
Queries if model is mutable.
An immutable GMenu::Model will never emit the #GMenuModel::items-changed signal. Consumers of the model may make optimisations accordingly.
#items_changed(position, removed, added) ⇒ nil
Requests emission of the GMenu::Model::items-changed signal on model.
This function should never be called except by GMenu::Model subclasses. Any other calls to this function will very likely lead to a violation of the interface of the model.
The implementation should update its internal representation of the menu before emitting the signal. The implementation should further expect to receive queries about the new state of the menu (and particularly added menu items) while signal handlers are running.
The implementation must dispatch this call directly from a mainloop entry and not in response to calls – particularly those from the GMenu::Model API. Said another way: the menu must not change while user code is running without returning to the mainloop.
#iterate_item_attributes(item_index) ⇒ Gio::MenuAttributeIter
Creates a GMenu::AttributeIter to iterate over the attributes of the item at position item_index in model.
You must free the iterator with g_object_unref() when you are done.
#iterate_item_links(item_index) ⇒ Gio::MenuLinkIter
Creates a GMenu::LinkIter to iterate over the links of the item at position item_index in model.
You must free the iterator with g_object_unref() when you are done.
#n_items ⇒ Integer
Query the number of items in model.