Next: <GMenuAttributeIter>, Previous: <GMemoryOutputStream>, Up: Classes   [Index]


1.52 <GMenu> ¶

Class: <GMenu> ¶

It derives from <GMenuModel>.

<GMenu> is a simple implementation of <GMenuModel>. You populate a <GMenu> by adding <GMenuItem> instances to it.

There are some convenience functions to allow you to directly add items (avoiding <GMenuItem>) for the common cases. To add a regular item, use menu:insert. To add a section, use menu:insert-section. To add a submenu, use menu:insert-submenu.

Procedures ¶

Method: menu:append self [label] [detailed-action] ¶
Method: append self [label] [detailed-action] ¶

Convenience function for appending a normal menu item to the end of self. Combine menu-item:new and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed, or left out: a string, or #f.

the section label, or #f

detailed-action

Passed, or left out: a string, or #f.

the detailed action string, or #f

Method: menu:append-item self item ¶
Method: append-item self item ¶

Appends item to the end of self.

See menu:insert-item for more information.

self

Passed: a <GMenu>.

a <GMenu>

item

Passed: a <GMenuItem>.

a <GMenuItem> to append

Method: menu:append-section self label section ¶
Method: append-section self label section ¶

Convenience function for appending a section menu item to the end of self. Combine menu-item:new-section and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed: a string, or #f.

the section label, or #f

section

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the section

Method: menu:append-submenu self label submenu ¶
Method: append-submenu self label submenu ¶

Convenience function for appending a submenu menu item to the end of self. Combine menu-item:new-submenu and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed: a string, or #f.

the section label, or #f

submenu

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the submenu

Method: menu:freeze self ¶
Method: freeze self ¶

Marks self as frozen.

After the menu is frozen, it is an error to attempt to make any changes to it. In effect this means that the <GMenu> API must no longer be used.

This function causes menu-model:is-mutable? to begin returning #f, which has some positive performance implications.

self

Passed: a <GMenu>.

a <GMenu>

Method: menu:insert self position [label] [detailed-action] ¶
Method: insert self position [label] [detailed-action] ¶

Convenience function for inserting a normal menu item into self. Combine menu-item:new and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

position

Passed: a 32-bit integer.

the position at which to insert the item

label

Passed, or left out: a string, or #f.

the section label, or #f

detailed-action

Passed, or left out: a string, or #f.

the detailed action string, or #f

Method: menu:insert-item self position item ¶
Method: insert-item self position item ¶

Inserts item into self.

The "insertion" is actually done by copying all of the attribute and link values of item and using them to form a new item within self. As such, item itself is not really inserted, but rather, a menu item that is exactly the same as the one presently described by item.

This means that item is essentially useless after the insertion occurs. Any changes you make to it are ignored unless it is inserted again (at which point its updated values will be copied).

You should probably just free item once you’re done.

There are many convenience functions to take care of common cases. See menu:insert, menu:insert-section and menu:insert-submenu as well as "prepend" and "append" variants of each of these functions.

self

Passed: a <GMenu>.

a <GMenu>

position

Passed: a 32-bit integer.

the position at which to insert the item

item

Passed: a <GMenuItem>.

the <GMenuItem> to insert

Method: menu:insert-section self position label section ¶
Method: insert-section self position label section ¶

Convenience function for inserting a section menu item into self. Combine menu-item:new-section and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

position

Passed: a 32-bit integer.

the position at which to insert the item

label

Passed: a string, or #f.

the section label, or #f

section

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the section

Method: menu:insert-submenu self position label submenu ¶
Method: insert-submenu self position label submenu ¶

Convenience function for inserting a submenu menu item into self. Combine menu-item:new-submenu and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

position

Passed: a 32-bit integer.

the position at which to insert the item

label

Passed: a string, or #f.

the section label, or #f

submenu

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the submenu

Procedure: menu:new ⇒ %return ¶

Creates a new <GMenu>.

The new menu has no items.

%return

Returned: a <GMenu>.

a new <GMenu>

Method: menu:prepend self [label] [detailed-action] ¶
Method: prepend self [label] [detailed-action] ¶

Convenience function for prepending a normal menu item to the start of self. Combine menu-item:new and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed, or left out: a string, or #f.

the section label, or #f

detailed-action

Passed, or left out: a string, or #f.

the detailed action string, or #f

Method: menu:prepend-item self item ¶
Method: prepend-item self item ¶

Prepends item to the start of self.

See menu:insert-item for more information.

self

Passed: a <GMenu>.

a <GMenu>

item

Passed: a <GMenuItem>.

a <GMenuItem> to prepend

Method: menu:prepend-section self label section ¶
Method: prepend-section self label section ¶

Convenience function for prepending a section menu item to the start of self. Combine menu-item:new-section and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed: a string, or #f.

the section label, or #f

section

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the section

Method: menu:prepend-submenu self label submenu ¶
Method: prepend-submenu self label submenu ¶

Convenience function for prepending a submenu menu item to the start of self. Combine menu-item:new-submenu and menu:insert-item for a more flexible alternative.

self

Passed: a <GMenu>.

a <GMenu>

label

Passed: a string, or #f.

the section label, or #f

submenu

Passed: a <GMenuModel>.

a <GMenuModel> with the items of the submenu

Method: menu:remove self position ¶
Method: remove self position ¶

Removes an item from the menu.

position gives the index of the item to remove.

It is an error if position is not in range the range from 0 to one less than the number of items in the menu.

It is not possible to remove items by identity since items are added to the menu simply by copying their links and attributes (ie: identity of the item itself is not preserved).

self

Passed: a <GMenu>.

a <GMenu>

position

Passed: a 32-bit integer.

the position of the item to remove

Method: menu:remove-all self ¶
Method: remove-all self ¶

Removes all items in the menu.

self

Passed: a <GMenu>.

a <GMenu>


Next: <GMenuAttributeIter>, Previous: <GMemoryOutputStream>, Up: Classes   [Index]