Update to 24f58c58bb8d22c0e8e6c5ce43c536c47b719bc6
[gnt.git] / gntmenu.h
blob4345ba74d23db16c2c6cc3c55064c0c70b3f870d
1 /**
2 * @file gntmenu.h Menu API
3 * @ingroup gnt
4 */
5 /*
6 * GNT - The GLib Ncurses Toolkit
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef GNT_MENU_H
28 #define GNT_MENU_H
30 #include "gnttree.h"
31 #include "gntcolors.h"
32 #include "gntkeys.h"
34 #define GNT_TYPE_MENU (gnt_menu_get_gtype())
35 #define GNT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_MENU, GntMenu))
36 #define GNT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_MENU, GntMenuClass))
37 #define GNT_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_MENU))
38 #define GNT_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_MENU))
39 #define GNT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_MENU, GntMenuClass))
41 #define GNT_MENU_FLAGS(obj) (GNT_MENU(obj)->priv.flags)
42 #define GNT_MENU_SET_FLAGS(obj, flags) (GNT_MENU_FLAGS(obj) |= flags)
43 #define GNT_MENU_UNSET_FLAGS(obj, flags) (GNT_MENU_FLAGS(obj) &= ~(flags))
45 typedef struct _GntMenu GntMenu;
46 typedef struct _GntMenuPriv GntMenuPriv;
47 typedef struct _GntMenuClass GntMenuClass;
49 #include "gntmenuitem.h"
51 /**
52 * A toplevel-menu is displayed at the top of the screen, and it spans accross
53 * the entire width of the screen.
54 * A popup-menu could be displayed, for example, as a context menu for widgets.
56 typedef enum
58 GNT_MENU_TOPLEVEL = 1, /* Menu for a toplevel window */
59 GNT_MENU_POPUP, /* A popup menu */
60 } GntMenuType;
62 struct _GntMenu
64 GntTree parent;
65 GntMenuType type;
67 GList *list;
68 int selected;
70 /* This will keep track of its immediate submenu which is visible so that
71 * keystrokes can be passed to it. */
72 GntMenu *submenu;
73 GntMenu *parentmenu;
76 struct _GntMenuClass
78 GntTreeClass parent;
80 void (*gnt_reserved1)(void);
81 void (*gnt_reserved2)(void);
82 void (*gnt_reserved3)(void);
83 void (*gnt_reserved4)(void);
86 G_BEGIN_DECLS
88 /**
89 * @return The GType for GntMenu.
91 GType gnt_menu_get_gtype(void);
93 /**
94 * Create a new menu.
96 * @param type The type of the menu, whether it's a toplevel menu or a popup menu.
98 * @return The newly created menu.
100 GntWidget * gnt_menu_new(GntMenuType type);
103 * Add an item to the menu.
105 * @param menu The menu.
106 * @param item The item to add to the menu.
108 void gnt_menu_add_item(GntMenu *menu, GntMenuItem *item);
111 * Return the GntMenuItem with the given ID.
113 * @param menu The menu.
114 * @param id The ID for an item.
116 * @return The menuitem with the given ID, or @c NULL.
118 * @since 2.3.0
120 GntMenuItem *gnt_menu_get_item(GntMenu *menu, const char *id);
122 G_END_DECLS
124 #endif /* GNT_MENU_H */