Gnome Developers' Information
<<< Previous | Automatic menu and toolbar creation with GnomeAppHelper | Next >>>

# Functions provided by GnomeAppHelper

The following is a list of the functions provided by GnomeAppHelper.

## gnome_app_find_menu_pos - return position of a menu item

`GtkWidget *`gnome_app_find_menu_pos``(GtkWidget *`root`, gchar *`path`, gint *`pos`);

### Description

For a menu item specified by `path`, returns item's parent GtkMenuShell and sets *pos to item's position in it if the item is found in the menu tree starting in GtkMenuShell root and NULL otherwise. New menus can later be inserted after the menu-item with a call to:

              gtk_menu_shell_insert(GTK_MENU_SHELL(parent), new_item, pos);

### Usage

    	  GnomeApp *app;
              GtkWidget *shell;
              gint pos;

              shell = gnome_app_find_menu_pos(app->menubar, "Edit/Sort/Ascending", &pos);

### Parameters

- GtkWidget *`root`

  The menu shell at the root of the menu subtree that is to be searched.

- gchar *`path`

  Menu path describing the searched-for item.

  - the path argument should be in the form "File/.../.../ItemName".

  - "" will return position before the first item in `root`.

  - "File/" will return position before the first item of the File submenu.

  - "File/Settings" will return position after the Settings item in the File submenu.

  - use of "File/<Separator>" should be obvious. However this stops after the first separator.

- gint *`pos`

  The integer pointed to by this parameter is set to the position of the menu item described by `path` in its parent menu shell.

## gnome_app_remove_menus - remove a number of menu items

`void `gnome_app_remove_menus``(GnomeApp *`app`, gchar *`path`, gint `item_count`);

### Description

This function removes `item_count` items from GnomeApp's menu structure, beginning with item described by `path`.

### Usage

                gnome_app_remove_menus(app, "Edit/Sort/Ascending", 2);

### Parameters

- GnomeApp *`app`

  The GnomeApp widget with the menubar containing the items to be removed.

- gchar *`path`

  Path describing the first item to be removed. See `gnome_app_find_menu_pos` for more information on menu paths.

- gint `item_count`

  Number of subsequent items to remove.

## gnome_app_insert_menus - insert menu structure in a GnomeApp's menubar

`void `gnome_app_insert_menus``(GnomeApp *`app`, gchar *`path`, GnomeUIInfo *`uiinfo`);

### Description

Inserts menu structure described by `uiinfo` at position described by `path`.

### Usage

    	    static GnomeUIInfo edit_menu[] = {
    	    { GNOME_APP_UI_ITEM, N_("_Copy"), N_("Copy text"), copy_callback, NULL, NULL,
    	      GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_COPY, 'c', GDK_CONTROL_MASK, NULL },
    	    { GNOME_APP_UI_ITEM, N_("C_ut..."), N_("Cut text"), cut_callback, NULL, NULL,
    	      GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CUT, 'x', GDK_CONTROL_MASK, NULL },
    	    { GNOME_APP_UI_ITEM, N_("_Paste"), N_("Paste clipboard contents"), paste_callback, NULL, NULL,
    	      GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PASTE, 'v', GDK_CONTROL_MASK, NULL },
    	    GNOMEUIINFO_END
    	    };

    	    static GnomeUIInfo more_menus[] = {
    	    { GNOME_APP_UI_ITEM, N_("_Search..."), N_("Search for text"), search_callback, NULL, NULL,
    	      GNOME_APP_PIXMAP_NONE, NULL, 's', GDK_CONTROL_MASK, NULL },
    	    { GNOME_APP_UI_ITEM, N_("_Replace..."), N_("Replace text"), replace_callback, NULL, NULL,
    	      GNOME_APP_PIXMAP_NONE, NULL, 'r', GDK_CONTROL_MASK, NULL },
    	    GNOMEUIINFO_END
    	    };

    	    static GnomeUIInfo main_menu[] = {
    	    GNOMEUIINFO_SUBTREE (N_("_Edit"), edit_menu),
    	    GNOMEUIINFO_END
    	    };

                app = gnome_app_new("app", "App");
                gnome_app_create_menus(app, main_menu);

                /* do something */

                /* insert Search and Replace items after Paste */
                gnome_app_insert_menus(app, "Edit/Paste", sort_menu);

### Parameters

- GnomeApp *`app`

  The GnomeApp containing the menubar in which the new items will be inserted.

- gchar *`path`

  Path describing the position where the new items will be insterted. See `gnome_app_find_menu_pos` for more information on menu paths.

- GnomeUIInfo *`uiinfo`

  A pointer to an array of GnomeUIInfo entries describing the menu items to insert.

<<< Previous | Home | Next >>>
Format information for the configuration of keybindings for standard mens | Up | The GnomeCanvas widget