[301:14] static extends: object
Alternate constructors for MenuItem. Usage:
MenuItemCtors.<name>(...). The primary constructor lives
directly on MenuItem.
newFromModel (object model, int item_index)
Creates a #GMenuItem as an exact copy of an existing menu item in a #GMenuModel. @item_index must be valid (ie: be sure to call g_menu_model_get_n_items() first).
model is a #GMenuModel.item_index is the index of an item in @model.A new MenuItem.newSection (string label, object section)
Creates a new #GMenuItem representing a section. This is a convenience API around g_menu_item_new() and g_menu_item_set_section(). The effect of having one menu appear as a section of another is exactly as it sounds: the items from @section become a direct part of the menu that @menu_item is added to. Visual separation is typically displayed between two non-empty sections. If @label is non-%NULL then it will be incorporated into this visual indication. This allows for labeled subsections of a menu. As a simple example, consider a typical "Edit" menu from a simple program. It probably contains an "Undo" and "Redo" item, followed by a separator, followed by "Cut", "Copy" and "Paste". This would be accomplished by creating three #GMenu instances. The first would be populated with the "Undo" and "Redo" items, and the second with the "Cut", "Copy" and "Paste" items. The first and second menus would then be added as submenus of the third. In XML format, this would look something like the following: |[
]| The following example is exactly equivalent. It is more illustrative of the exact relationship between the menus and items (keeping in mind that the 'link' element defines a new menu that is linked to the containing one). The style of the second example is more verbose and difficult to read (and therefore not recommended except for the purpose of understanding what is really going on). |[ ]|
label is the section label, or %NULL.section is a #GMenuModel with the items of the section.A new MenuItem.newSubmenu (string label, object submenu)
Creates a new #GMenuItem representing a submenu. This is a convenience API around g_menu_item_new() and g_menu_item_set_submenu().
label is the section label, or %NULL.submenu is a #GMenuModel with the items of the submenu.A new MenuItem.[13:7] extends: object
#GMenuItem is an opaque structure type. You must access it using the functions below.
MenuItem (label = null, detailed_action = null)
Creates a new #GMenuItem. If @label is non-%NULL it is used to set the "label" attribute of the new item. If @detailed_action is non-%NULL it is used to set the "action" and possibly the "target" attribute of the new item. See g_menu_item_set_detailed_action() for more information.
label is the section label, or %NULL.detailed_action is the detailed action string, or %NULL.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asObject ()
Wraps this handle as
Object.
A Object object.get_attribute_value (string attribute, object expected_type)
Queries the named @attribute on @menu_item. If @expected_type is specified and the attribute does not have this type, %NULL is returned. %NULL is also returned if the attribute simply does not exist.
attribute is the attribute name to query.expected_type is the expected type of the attribute.get_link (string link)
Queries the named @link on @menu_item.
link is the link name to query.set_action_and_target_value (string action, object target_value)
Sets or unsets the "action" and "target" attributes of @menu_item. If
is %NULL then both the "action" and "target" attributes are unset (and @target_value is ignored). If @action is non-%NULL then the "action" attribute is set. The "target" attribute is then set to the value ofif it is non-%NULL or unset otherwise. Normal menu items (ie: not submenu, section or other custom item types) are expected to have the "action" attribute set to identify the action that they are associated with. The state type of the action help to determine the disposition of the menu item. See #GAction and #GActionGroup for an overview of actions. In general, clicking on the menu item will result in activation of the named action with the "target" attribute given as the parameter to the action invocation. If the "target" attribute is not set then the action is invoked with no parameter. If the action has no state then the menu item is usually drawn as a plain menu item (ie: with no additional decoration). If the action has a boolean state then the menu item is usually drawn as a toggle menu item (ie: with a checkmark or equivalent indication). The item should be marked as 'toggled' or 'checked' when the boolean state is %TRUE. If the action has a string state then the menu item is usually drawn as a radio menu item (ie: with a radio bullet or equivalent indication). The item should be marked as 'selected' when the string state is equal to the value of the @target property. See g_menu_item_set_action_and_target() or g_menu_item_set_detailed_action() for two equivalent calls that are probably more convenient for most uses.action is the name of the action for this item.target_value is a #GVariant to use as the action target.None.set_attribute_value (string attribute, object value)
Sets or unsets an attribute on @menu_item. The attribute to set or unset is specified by @attribute. This can be one of the standard attribute names %G_MENU_ATTRIBUTE_LABEL, %G_MENU_ATTRIBUTE_ACTION, %G_MENU_ATTRIBUTE_TARGET, or a custom attribute name. Attribute names are restricted to lowercase characters, numbers and '-'. Furthermore, the names must begin with a lowercase character, must not end with a '-', and must not contain consecutive dashes. must consist only of lowercase ASCII characters, digits and '-'. If @value is non-%NULL then it is used as the new value for the attribute. If @value is %NULL then the attribute is unset. If the @value #GVariant is floating, it is consumed. See also g_menu_item_set_attribute() for a more convenient way to do the same.
attribute is the attribute to set.value is a #GVariant to use as the value, or %NULL.None.set_detailed_action (string detailed_action)
Sets the "action" and possibly the "target" attribute of @menu_item. The format of @detailed_action is the same format parsed by g_action_parse_detailed_name(). See g_menu_item_set_action_and_target() or g_menu_item_set_action_and_target_value() for more flexible (but slightly less convenient) alternatives. See also g_menu_item_set_action_and_target_value() for a description of the semantics of the action and target attributes.
detailed_action is the "detailed" action string.None.set_icon (object icon)
Sets (or unsets) the icon on @menu_item. This call is the same as calling g_icon_serialize() and using the result as the value to g_menu_item_set_attribute_value() for %G_MENU_ATTRIBUTE_ICON. This API is only intended for use with "noun" menu items; things like bookmarks or applications in an "Open With" menu. Don't use it on menu items corresponding to verbs (eg: stock icons for 'Save' or 'Quit'). If @icon is %NULL then the icon is unset.
icon is a #GIcon, or %NULL.None.set_label (string label)
Sets or unsets the "label" attribute of @menu_item. If @label is non-%NULL it is used as the label for the menu item. If it is %NULL then the label attribute is unset.
label is the label to set, or %NULL to unset.None.set_link (string link, object model)
Creates a link from @menu_item to @model if non-%NULL, or unsets it. Links are used to establish a relationship between a particular menu item and another menu. For example, %G_MENU_LINK_SUBMENU is used to associate a submenu with a particular menu item, and %G_MENU_LINK_SECTION is used to create a section. Other types of link can be used, but there is no guarantee that clients will be able to make sense of them. Link types are restricted to lowercase characters, numbers and '-'. Furthermore, the names must begin with a lowercase character, must not end with a '-', and must not contain consecutive dashes.
link is type of link to establish or unset.model is the #GMenuModel to link to (or %NULL to unset).None.set_section (object section)
Sets or unsets the "section" link of @menu_item to @section. The effect of having one menu appear as a section of another is exactly as it sounds: the items from @section become a direct part of the menu that
is added to. See g_menu_item_new_section() for more information about what it means for a menu item to be a section.section is a #GMenuModel, or %NULL.None.set_submenu (object submenu)
Sets or unsets the "submenu" link of @menu_item to @submenu. If @submenu is non-%NULL, it is linked to. If it is %NULL then the link is unset. The effect of having one menu appear as a submenu of another is exactly as it sounds.
submenu is a #GMenuModel, or %NULL.None.