Class: Gio::MenuModel

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

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.

Parameters:

  • item_index (Integer)

    the index of the item

  • attribute (String)

    the attribute to query

  • format_string (String)

    a #GVariant format string

  • array (Array)

    positional parameters, as per format_string

Returns:

  • (TrueClass)

    true if the named attribute was found with the expected type

#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.

Parameters:

  • item_index (Integer)

    the index of the item

  • attribute (String)

    the attribute to query

  • expected_type (GLib::VariantType)

    the expected type of the attribute, or nil

Returns:

  • (GLib::Variant)

    the value of the attribute

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.

Parameters:

  • item_index (Integer)

    the index of the item

  • link (String)

    the link to query

Returns:

#is_mutableTrueClass

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.

Returns:

  • (TrueClass)

    true if the model is mutable (ie: “items-changed” may be emitted).

#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.

Parameters:

  • position (Integer)

    the position of the change

  • removed (Integer)

    the number of items removed

  • added (Integer)

    the number of items added

Returns:

  • (nil)

#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.

Parameters:

  • item_index (Integer)

    the index of the item

Returns:

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.

Parameters:

  • item_index (Integer)

    the index of the item

Returns:

#n_itemsInteger

Query the number of items in model.

Returns:

  • (Integer)

    the number of items