Package ch.bailu.gtk.gio
Class MenuItem
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gio.MenuItem
- All Implemented Interfaces:
PointerInterface
#GMenuItem is an opaque structure type. You must access it using the
functions below.
functions below.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getAttribute
(Str attribute, Str format_string, Object... _elipse) Queries the named @attribute on @menu_item.boolean
getAttribute
(String attribute, String format_string, Object... _elipse) Queries the named @attribute on @menu_item.getAttributeValue
(Str attribute, VariantType expected_type) Queries the named @attribute on @menu_item.getAttributeValue
(String attribute, VariantType expected_type) Queries the named @attribute on @menu_item.static ClassHandler
static int
Queries the named @link on @menu_item.Queries the named @link on @menu_item.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
static MenuItem
newFromModelMenuItem
(MenuModel model, int item_index) Creates a #GMenuItem as an exact copy of an existing menu item in a
#GMenuModel.static MenuItem
newSectionMenuItem
(Str label, MenuModel section) Creates a new #GMenuItem representing a section.static MenuItem
newSectionMenuItem
(String label, MenuModel section) Creates a new #GMenuItem representing a section.static MenuItem
newSubmenuMenuItem
(Str label, MenuModel submenu) Creates a new #GMenuItem representing a submenu.static MenuItem
newSubmenuMenuItem
(String label, MenuModel submenu) Creates a new #GMenuItem representing a submenu.void
setActionAndTarget
(Str action, Str format_string, Object... _elipse) Sets or unsets the "action" and "target" attributes of @menu_item.void
setActionAndTarget
(String action, String format_string, Object... _elipse) Sets or unsets the "action" and "target" attributes of @menu_item.void
setActionAndTargetValue
(Str action, Variant target_value) Sets or unsets the "action" and "target" attributes of @menu_item.void
setActionAndTargetValue
(String action, Variant target_value) Sets or unsets the "action" and "target" attributes of @menu_item.void
setAttribute
(Str attribute, Str format_string, Object... _elipse) Sets or unsets an attribute on @menu_item.void
setAttribute
(String attribute, String format_string, Object... _elipse) Sets or unsets an attribute on @menu_item.void
setAttributeValue
(Str attribute, Variant value) Sets or unsets an attribute on @menu_item.void
setAttributeValue
(String attribute, Variant value) Sets or unsets an attribute on @menu_item.void
setDetailedAction
(Str detailed_action) Sets the "action" and possibly the "target" attribute of @menu_item.void
setDetailedAction
(String detailed_action) Sets the "action" and possibly the "target" attribute of @menu_item.void
Sets (or unsets) the icon on @menu_item.void
Sets or unsets the "label" attribute of @menu_item.void
Sets or unsets the "label" attribute of @menu_item.void
Creates a link from @menu_item to @model if non-%NULL, or unsets it.void
Creates a link from @menu_item to @model if non-%NULL, or unsets it.void
setSection
(MenuModel section) Sets or unsets the "section" link of @menu_item to @section.void
setSubmenu
(MenuModel submenu) Sets or unsets the "submenu" link of @menu_item to @submenu.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
MenuItem
-
MenuItem
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.- Parameters:
label
- the section label, or %NULLdetailed_action
- the detailed action string, or %NULL
-
MenuItem
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.- Parameters:
label
- the section label, or %NULLdetailed_action
- the detailed action string, or %NULL
-
-
Method Details
-
getClassHandler
-
newFromModelMenuItem
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).- Parameters:
model
- a #GMenuModelitem_index
- the index of an item in @model- Returns:
- a new #GMenuItem.
-
newSectionMenuItem
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 encorporated 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:<menu id='edit-menu'> <section> <item label='Undo'/> <item label='Redo'/> </section> <section> <item label='Cut'/> <item label='Copy'/> <item label='Paste'/> </section> </menu>
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).<menu id='edit-menu'> <item> <link name='section'> <item label='Undo'/> <item label='Redo'/> </link> </item> <item> <link name='section'> <item label='Cut'/> <item label='Copy'/> <item label='Paste'/> </link> </item> </menu>
- Parameters:
label
- the section label, or %NULLsection
- a #GMenuModel with the items of the section- Returns:
- a new #GMenuItem
-
newSectionMenuItem
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 encorporated 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:<menu id='edit-menu'> <section> <item label='Undo'/> <item label='Redo'/> </section> <section> <item label='Cut'/> <item label='Copy'/> <item label='Paste'/> </section> </menu>
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).<menu id='edit-menu'> <item> <link name='section'> <item label='Undo'/> <item label='Redo'/> </link> </item> <item> <link name='section'> <item label='Cut'/> <item label='Copy'/> <item label='Paste'/> </link> </item> </menu>
- Parameters:
label
- the section label, or %NULLsection
- a #GMenuModel with the items of the section- Returns:
- a new #GMenuItem
-
getAttribute
Queries the named @attribute on @menu_item.
If the attribute exists and matches the #GVariantType 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.- Parameters:
attribute
- the attribute name to queryformat_string
- a #GVariant format string_elipse
- positional parameters, as per @format_string- Returns:
- %TRUE if the named attribute was found with the expected type
-
getAttribute
Queries the named @attribute on @menu_item.
If the attribute exists and matches the #GVariantType 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.- Parameters:
attribute
- the attribute name to queryformat_string
- a #GVariant format string_elipse
- positional parameters, as per @format_string- Returns:
- %TRUE if the named attribute was found with the expected type
-
getAttributeValue
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.- Parameters:
attribute
- the attribute name to queryexpected_type
- the expected type of the attribute- Returns:
- the attribute value, or %NULL
-
getAttributeValue
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.- Parameters:
attribute
- the attribute name to queryexpected_type
- the expected type of the attribute- Returns:
- the attribute value, or %NULL
-
getLink
Queries the named @link on @menu_item.- Parameters:
link
- the link name to query- Returns:
- the link, or %NULL
-
getLink
Queries the named @link on @menu_item.- Parameters:
link
- the link name to query- Returns:
- the link, or %NULL
-
setActionAndTarget
public void setActionAndTarget(@Nullable Str action, @Nullable Str format_string, Object... _elipse) Sets or unsets the "action" and "target" attributes of @menu_item.
If @action is %NULL then both the "action" and "target" attributes
are unset (and @format_string is ignored along with the positional
parameters).
If @action is non-%NULL then the "action" attribute is set.
@format_string is then inspected. If it is non-%NULL then the proper
position parameters are collected to create a #GVariant instance to
use as the target value. If it is %NULL then the positional
parameters are ignored and the "target" attribute is unset.
See also g_menu_item_set_action_and_target_value() for an equivalent
call that directly accepts a #GVariant. See
g_menu_item_set_detailed_action() for a more convenient version that
works with string-typed targets.
See also g_menu_item_set_action_and_target_value() for a
description of the semantics of the action and target attributes.- Parameters:
action
- the name of the action for this itemformat_string
- a GVariant format string_elipse
- positional parameters, as per @format_string
-
setActionAndTarget
Sets or unsets the "action" and "target" attributes of @menu_item.
If @action is %NULL then both the "action" and "target" attributes
are unset (and @format_string is ignored along with the positional
parameters).
If @action is non-%NULL then the "action" attribute is set.
@format_string is then inspected. If it is non-%NULL then the proper
position parameters are collected to create a #GVariant instance to
use as the target value. If it is %NULL then the positional
parameters are ignored and the "target" attribute is unset.
See also g_menu_item_set_action_and_target_value() for an equivalent
call that directly accepts a #GVariant. See
g_menu_item_set_detailed_action() for a more convenient version that
works with string-typed targets.
See also g_menu_item_set_action_and_target_value() for a
description of the semantics of the action and target attributes.- Parameters:
action
- the name of the action for this itemformat_string
- a GVariant format string_elipse
- positional parameters, as per @format_string
-
setActionAndTargetValue
Sets or unsets the "action" and "target" attributes of @menu_item.
If @action 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 of @target_value if 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.- Parameters:
action
- the name of the action for this itemtarget_value
- a #GVariant to use as the action target
-
setActionAndTargetValue
Sets or unsets the "action" and "target" attributes of @menu_item.
If @action 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 of @target_value if 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.- Parameters:
action
- the name of the action for this itemtarget_value
- a #GVariant to use as the action target
-
setAttribute
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.
If @format_string is non-%NULL then the proper position parameters
are collected to create a #GVariant instance to use as the attribute
value. If it is %NULL then the positional parameterrs are ignored
and the named attribute is unset.
See also g_menu_item_set_attribute_value() for an equivalent call
that directly accepts a #GVariant.- Parameters:
attribute
- the attribute to setformat_string
- a #GVariant format string, or %NULL_elipse
- positional parameters, as per @format_string
-
setAttribute
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.
If @format_string is non-%NULL then the proper position parameters
are collected to create a #GVariant instance to use as the attribute
value. If it is %NULL then the positional parameterrs are ignored
and the named attribute is unset.
See also g_menu_item_set_attribute_value() for an equivalent call
that directly accepts a #GVariant.- Parameters:
attribute
- the attribute to setformat_string
- a #GVariant format string, or %NULL_elipse
- positional parameters, as per @format_string
-
setAttributeValue
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.- Parameters:
attribute
- the attribute to setvalue
- a #GVariant to use as the value, or %NULL
-
setAttributeValue
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.- Parameters:
attribute
- the attribute to setvalue
- a #GVariant to use as the value, or %NULL
-
setDetailedAction
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.- Parameters:
detailed_action
- the "detailed" action string
-
setDetailedAction
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.- Parameters:
detailed_action
- the "detailed" action string
-
setIcon
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.- Parameters:
icon
- a #GIcon, or %NULL
-
setLabel
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.- Parameters:
label
- the label to set, or %NULL to unset
-
setLabel
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.- Parameters:
label
- the label to set, or %NULL to unset
-
setLink
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.- Parameters:
link
- type of link to establish or unsetmodel
- the #GMenuModel to link to (or %NULL to unset)
-
setLink
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.- Parameters:
link
- type of link to establish or unsetmodel
- the #GMenuModel to link to (or %NULL to unset)
-
setSection
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 @menu_item is added to. See g_menu_item_new_section()
for more information about what it means for a menu item to be a
section.- Parameters:
section
- a #GMenuModel, or %NULL
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-