Previous Up Next

KPlug Glade Tutorial

The Glade Menu Editor

When you set up an application window or a menu bar, you will need to use the menu editor in order to create the interface's dropdown menus. This editor isn't very difficult to learn, some of its main points are explained below. You can find the editor in the properties window when the menu bar is selected from the display or the widget tree window

The illustration to the right shows the menu editor pulled up on a stock Gnome application window. The 'New File' element of that menubar is highlighted. It is a stock item, and so it will have a stock 'new file' icon (and the icon can't be set from the menu editor). Its handler is on_new_file1_activate(). When the project is saved and the code is built, this handler will show up in callbacks.c Other than that, the menu bar runs itself, creating the dropdowns when the user clicks on the header in the menu bar.

The Glade Menu Editor
 

The Menu Editor has a window area which shows a list of the menu items, their 'headers' and such, an area for specifying menu item properties (name, label, etc), an area for setting item types so you can have lists of check and radio buttons, an area for setting accelerators, and several different self explanatory buttons.

The List View: A menu item's position in the list view determines where in the menu bar the item will appear. If the item is all the way over to the left, it will appear on the menu bar when the application is started. If it is shifted to the right under one of the above items, it will be on a sub menu. You can have submenus in submenus as well. Each of the 'headers' for a submenu has no handler. Its submenu is brought up automatically by the widget when it's clicked. In the illustration the 'File' menu item appears on the menu bar when the application is started. When it is clicked, the 'New File', 'Open', 'Save', 'Save As', '---', and 'Exit' items appear in its submenu. --- is a separator, and does nothing.

To shift the menu items to the right and left, or up and down (and hence into new submenus) use the arrow keys under the menu listing window.

Manipulating Items: To add or delete an item, or add a seperator, use the add, add seperator and delete buttons. Add and add seperator will add the new menuitem below the position of your cursor in the menu listing window. Delete will delete whatever the cursor is on in the menu listing window.

The basic items in the Menu Editor are as follows:

  • Stock Item: This is a dropdown list from which you can pick a stock item, if you want it. When you pick it, everything else in the menu, ie the name, handler etc, will change accordingly.
  • Label: This is what appears on the menu. An underscore before a letter here indicates the accelerator for that menu item.
  • Name: This is the name of the menu item as it appears in the code. It should be unique.
  • Handler: This is the handler for the menu item, which will be listed in callbacks.c. It too should be unique.
  • Icon: If this is not a stock menu item, you might want to supply an icon. This isn't required though.
  • Tooltip: What the tooltip should say when the user hovers the mouse over this menu item. This doesn't have to be set, but it's nice.

Radio and Check Items: If you add a custom menu item you can set it to be of radio or check type. See the radio and check button widgets for more on these. Note that you'll have to tell which group the radio items are in so they will work correctly.

Accelerators: Add keyboard accelerators for your custom menu items here. Stock menu items already have them.

Previous Up Next