bind_model


Description:

public void bind_model (MenuModel? model, string? action_namespace)

Establishes a binding between a Popover and a MenuModel.

The contents of this are removed and then refilled with menu items according to model. When model changes, this is updated. Calling this function twice on this with different model will cause the first binding to be replaced with a binding to the new model. If model is null then any previous binding is undone and all children are removed.

If action_namespace is non-null 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 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 outside of a ApplicationWindow, then you will need to attach your own action group to the widget hierarchy using 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 MenuModel.

Parameters:

this

a Popover

model

the MenuModel to bind to or null to remove binding

action_namespace

the namespace for actions in model




2022 vala-language.org