## SwamiguiItemMenu SwamiguiItemMenu |

## Synopsis

                        SwamiguiItemMenuInfo;
                        SwamiguiItemMenuEntry;
    void                (*SwamiguiItemMenuCallback)         (IpatchList *selection,
                                                             gpointer data);
    void                (*SwamiguiItemMenuHandler)          (SwamiguiItemMenu *menu,
                                                             const char *action_id);
    enum                SwamiguiItemMenuFlags;
                        SwamiguiItemMenu;
    extern              GtkAccelGroup *swamigui_item_menu_accel_group;
    SwamiguiItemMenu *  swamigui_item_menu_new              ();
    GtkWidget *         swamigui_item_menu_add              (SwamiguiItemMenu *menu,
                                                             const SwamiguiItemMenuInfo *info,
                                                             const char *action_id);
    GtkWidget *         swamigui_item_menu_add_registered_info
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);
    void                swamigui_item_menu_generate         (SwamiguiItemMenu *menu);
    void                swamigui_register_item_menu_action  (char *action_id,
                                                             SwamiguiItemMenuInfo *info,
                                                             SwamiguiItemMenuHandler handler);
    gboolean            swamigui_lookup_item_menu_action    (const char *action_id,
                                                             SwamiguiItemMenuInfo **info,
                                                             SwamiguiItemMenuHandler *handler);
    void                swamigui_register_item_menu_include_type
                                                            (const char *action_id,
                                                             GType type,
                                                             gboolean derived);
    void                swamigui_register_item_menu_exclude_type
                                                            (const char *action_id,
                                                             GType type,
                                                             gboolean derived);
    gboolean            swamigui_test_item_menu_type        (const char *action_id,
                                                             GType type);
    gboolean            swamigui_test_item_menu_include_type
                                                            (const char *action_id,
                                                             GType type);
    gboolean            swamigui_test_item_menu_exclude_type
                                                            (const char *action_id,
                                                             GType type);
    GObject *           swamigui_item_menu_get_selection_single
                                                            (SwamiguiItemMenu *menu);
    IpatchList *        swamigui_item_menu_get_selection    (SwamiguiItemMenu *menu);
    void                swamigui_item_menu_handler_single   (SwamiguiItemMenu *menu,
                                                             const char *action_id);
    void                swamigui_item_menu_handler_multi    (SwamiguiItemMenu *menu,
                                                             const char *action_id);
    void                swamigui_item_menu_handler_single_all
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);
    void                swamigui_item_menu_handler_multi_all
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkContainer
                               +----GtkMenuShell
                                     +----GtkMenu
                                           +----SwamiguiItemMenu

## Implemented Interfaces

SwamiguiItemMenu implements AtkImplementorIface and GtkBuildable.

## Properties

      "creator"                  GObject*              : Read / Write
      "right-click"              GObject*              : Read / Write
      "selection"                IpatchList*           : Read / Write

## Description

## Details

### SwamiguiItemMenuInfo

    typedef struct {
      guint order; /* an integer used to sort items (lower values first) */
      char *label;			/* menu label text */
      char *accel;			/* key accelerator */
      char *icon;			/* stock ID of icon */
      guint flags;			/* SwamiguiItemMenuFlags */
      SwamiguiItemMenuCallback func; /* function to call when item is activated */
      gpointer data;		/* data to pass to callback function */
    } SwamiguiItemMenuInfo;

### SwamiguiItemMenuEntry

    typedef struct _SwamiguiItemMenuEntry SwamiguiItemMenuEntry;

### SwamiguiItemMenuCallback ()

    void                (*SwamiguiItemMenuCallback)         (IpatchList *selection,
                                                             gpointer data);

A callback function type that is used when a menu item is activated.

`selection` : | Item selection
`data` : | Data defined by the menu item

### SwamiguiItemMenuHandler ()

    void                (*SwamiguiItemMenuHandler)          (SwamiguiItemMenu *menu,
                                                             const char *action_id);

A handler for a menu item type. Called when generating a menu for an item selection and right click item. This function should determine if its action type (example: paste, delete, copy, new, etc) is valid for the given selection and add one or more menu items if so.

`menu` : | GUI menu object
`action_id` : | Menu action ID (set when action was registered)

### enum SwamiguiItemMenuFlags

    typedef enum  /*< flags >*/
    {
      SWAMIGUI_ITEM_MENU_INACTIVE = 1 << 0,	/* set if menu item should be inactive */
      SWAMIGUI_ITEM_MENU_PLUGIN   = 1 << 1	/* set if menu item is for a plugin */
    } SwamiguiItemMenuFlags;

### SwamiguiItemMenu

    typedef struct _SwamiguiItemMenu SwamiguiItemMenu;

### swamigui_item_menu_accel_group

    extern GtkAccelGroup *swamigui_item_menu_accel_group;

### swamigui_item_menu_new ()

    SwamiguiItemMenu *  swamigui_item_menu_new              ();

Create a new Swami tree store.

Returns : | New Swami tree store object with a ref count of 1.

### swamigui_item_menu_add ()

    GtkWidget *         swamigui_item_menu_add              (SwamiguiItemMenu *menu,
                                                             const SwamiguiItemMenuInfo *info,
                                                             const char *action_id);

Add a menu item to a GUI menu.

`menu` : | GUI menu to add item to
`info` : | Info describing new menu item to add
`action_id` : | The action ID string that is adding the menu item
Returns : | The new GtkMenuItem that was added to the menu.

### swamigui_item_menu_add_registered_info ()

    GtkWidget *         swamigui_item_menu_add_registered_info
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);

Add a menu item to a GUI menu using the default info added when the `action_id` was registered.

`menu` : | GUI menu to add item to
`action_id` : | The action ID string that is adding the menu item
Returns : | The new GtkMenuItem that was added to the menu.

### swamigui_item_menu_generate ()

    void                swamigui_item_menu_generate         (SwamiguiItemMenu *menu);

Generate a GUI menu by executing all registered item action handlers which add items to the menu. Any existing items are removed before generating the new menu.

`menu` : | GUI menu

### swamigui_register_item_menu_action ()

    void                swamigui_register_item_menu_action  (char *action_id,
                                                             SwamiguiItemMenuInfo *info,
                                                             SwamiguiItemMenuHandler handler);

Registers a menu action.

`action_id` : | Menu item action ID (example: "paste", "new", "copy", etc), should be a static string since it is used directly.
`info` : | Menu item info (optional if `handler` specified). Structure is used directly and so it should be static as well as the strings inside.
`handler` : | Function to call when generating a menu (may be `NULL` in which case the default handler is used). Handler function should determine whether the registered action is appropriate for the current item selection and right click item and add menu items as appropriate.

### swamigui_lookup_item_menu_action ()

    gboolean            swamigui_lookup_item_menu_action    (const char *action_id,
                                                             SwamiguiItemMenuInfo **info,
                                                             SwamiguiItemMenuHandler *handler);

Lookup item action information registered by `action_id`.

`action_id` : | ID string of item menu action to lookup.
`info` : | Location to store pointer to registered info (or `NULL` to ignore).
`handler` : | Location to store pointer to registered handler (or `NULL` to ignore).
Returns : | `TRUE` if action found by `action_id`, `FALSE` if not found.

### swamigui_register_item_menu_include_type ()

    void                swamigui_register_item_menu_include_type
                                                            (const char *action_id,
                                                             GType type,
                                                             gboolean derived);

Adds a selection item type for inclusion for the given registered item action.

`action_id` : | The registered action ID string
`type` : | The type to add
`derived` : | Set to `TRUE` if derived types should match also

### swamigui_register_item_menu_exclude_type ()

    void                swamigui_register_item_menu_exclude_type
                                                            (const char *action_id,
                                                             GType type,
                                                             gboolean derived);

Adds a selection item type for exclusion for the given registered item action.

`action_id` : | The registered action ID string
`type` : | The type to add
`derived` : | Set to `TRUE` if derived types should match also

### swamigui_test_item_menu_type ()

    gboolean            swamigui_test_item_menu_type        (const char *action_id,
                                                             GType type);

Tests if a given item selection `type` is in the include list and not in the exclude list for `action_id`.

`action_id` : | Menu item action ID string
`type` : | Type to test
Returns : | `TRUE` if item is in include list and not in exclude list for `action_id`, `FALSE` otherwise.

### swamigui_test_item_menu_include_type ()

    gboolean            swamigui_test_item_menu_include_type
                                                            (const char *action_id,
                                                             GType type);

Tests if a given item selection `type` is in the include list for `action_id`.

`action_id` : | Menu item action ID string
`type` : | Type to test
Returns : | `TRUE` if item is in include list for `action_id`, `FALSE` otherwise.

### swamigui_test_item_menu_exclude_type ()

    gboolean            swamigui_test_item_menu_exclude_type
                                                            (const char *action_id,
                                                             GType type);

Tests if a given item selection `type` is not in the exclude list for `action_id`.

`action_id` : | Menu item action ID string
`type` : | Type to test
Returns : | `TRUE` if item is not in exclude list for `action_id` (should be included), `FALSE` otherwise.

### swamigui_item_menu_get_selection_single ()

    GObject *           swamigui_item_menu_get_selection_single
                                                            (SwamiguiItemMenu *menu);

Test if a menu object has a single selected item and return it if so.

`menu` : | GUI menu object
Returns : | The single selected item object or `NULL` if not a single selection. Returned object does NOT have a reference added and should be referenced if used outside of calling function.

### swamigui_item_menu_get_selection ()

    IpatchList *        swamigui_item_menu_get_selection    (SwamiguiItemMenu *menu);

Test if a menu object has any selected items and return the selection list if so.

`menu` : | GUI menu object
Returns : | Selected items or `NULL` if no selection object. No reference is added for caller, so caller must reference if used outside of calling context.

### swamigui_item_menu_handler_single ()

    void                swamigui_item_menu_handler_single   (SwamiguiItemMenu *menu,
                                                             const char *action_id);

A SwamiguiItemMenuHandler type that can be used when registering a menu action. It will add a single menu item, using the info provided during action registration, if a single item is selected and is of a type found in the include type list and not found in exclude list.

`menu` : | The menu object
`action_id` : | The action ID

### swamigui_item_menu_handler_multi ()

    void                swamigui_item_menu_handler_multi    (SwamiguiItemMenu *menu,
                                                             const char *action_id);

A SwamiguiItemMenuHandler type that can be used when registering a menu action. It will add a single menu item, using the info provided during action registration, if a single item is selected and is of a type found in the include type list and not in exclude list or multiple items are selected.

`menu` : | The menu object
`action_id` : | The action ID

### swamigui_item_menu_handler_single_all ()

    void                swamigui_item_menu_handler_single_all
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);

A SwamiguiItemMenuHandler type that can be used when registering a menu action. It will add a single menu item, using the info provided during action registration, if there is a single item selected of any type.

`menu` : | The menu object
`action_id` : | The action ID

### swamigui_item_menu_handler_multi_all ()

    void                swamigui_item_menu_handler_multi_all
                                                            (SwamiguiItemMenu *menu,
                                                             const char *action_id);

A SwamiguiItemMenuHandler type that can be used when registering a menu action. It will add a single menu item, using the info provided during action registration, if there is at least one item selected of any type.

`menu` : | The menu object
`action_id` : | The action ID

## Property Details

### The `"creator"` property

      "creator"                  GObject*              : Read / Write

creator.

### The `"right-click"` property

      "right-click"              GObject*              : Read / Write

right-click.

### The `"selection"` property

      "selection"                IpatchList*           : Read / Write

selection.