EFL 1.7 svn doobies
[profile/ivi/efreet.git] / src / lib / efreet_menu.h
1 #ifndef EFREET_MENU_H
2 #define EFREET_MENU_H
3
4 /**
5  * @file efreet_menu.h
6  * @brief Contains the structures and methods to support the Desktop
7  * Menu Specification.
8  * @addtogroup Efreet_Menu Efreet_Menu: The FDO Desktop Menu Specification
9  * functions and structures
10  *
11  * @{
12  */
13
14 /**
15  * The type of entry
16  */
17 typedef enum Efreet_Menu_Entry_Type
18 {
19     EFREET_MENU_ENTRY_MENU,
20     EFREET_MENU_ENTRY_DESKTOP,
21     EFREET_MENU_ENTRY_SEPARATOR,
22     EFREET_MENU_ENTRY_HEADER
23 } Efreet_Menu_Entry_Type;
24
25 /**
26  * Efreet_Menu
27  */
28 typedef struct Efreet_Menu Efreet_Menu;
29
30 /**
31  * Efreet_Menu
32  * Stores information on a entry in the menu
33  */
34 struct Efreet_Menu
35 {
36     Efreet_Menu_Entry_Type type;
37     const char *id;   /**< File-id for desktop and relative name for menu */
38
39     const char *name; /**< Name this entry should show */
40     const char *icon; /**< Icon for this entry */
41
42     Efreet_Desktop *desktop;   /**< The desktop we refer too */
43     Eina_List      *entries;   /**< The menu items */
44 };
45
46
47 /**
48  * @return Returns no value
49  * @brief Initialize legacy kde support. This function blocks while
50  * the kde-config script is run.
51  */
52 EAPI int              efreet_menu_kde_legacy_init(void);
53
54 /**
55  * @param name The internal name of the menu
56  * @return Returns the Efreet_Menu on success or
57  * NULL on failure
58  * @brief Creates a new menu
59  */
60 EAPI Efreet_Menu     *efreet_menu_new(const char *name);
61
62 /**
63  * @brief Override which file is used for menu creation
64  * @param file The file to use for menu creation
65  *
66  * This file is only used if it exists, else the standard files will be used
67  * for the menu.
68  */
69 EAPI void             efreet_menu_file_set(const char *file);
70
71 /**
72  * @return Returns the Efreet_Menu_Internal representation of the default menu or
73  * NULL if none found
74  * @brief Creates the default menu representation
75  */
76 EAPI Efreet_Menu     *efreet_menu_get(void);
77
78 /**
79  * @param path The path of the menu to load
80  * @return Returns the Efreet_Menu_Internal representation on success or NULL on
81  * failure
82  * @brief Parses the given .menu file and creates the menu representation
83  */
84 EAPI Efreet_Menu     *efreet_menu_parse(const char *path);
85
86 /**
87  * @param menu The menu to work with
88  * @param path The path where the menu should be saved
89  * @return Returns 1 on success, 0 on failure
90  * @brief Saves the menu to file
91  */
92 EAPI int              efreet_menu_save(Efreet_Menu *menu, const char *path);
93
94 /**
95  * @param menu The Efreet_Menu to free
96  * @return Returns no value
97  * @brief Frees the given structure
98  */
99 EAPI void             efreet_menu_free(Efreet_Menu *menu);
100
101
102 /**
103  * @param menu The menu to work with
104  * @param desktop The desktop to insert
105  * @param pos The position to place the new desktop
106  * @return Returns 1 on success, 0 on failure
107  * @brief Insert a desktop element in a menu structure. Only accepts desktop files
108  * in default directories.
109  */
110 EAPI int              efreet_menu_desktop_insert(Efreet_Menu *menu,
111                                                     Efreet_Desktop *desktop,
112                                                     int pos);
113
114 /**
115  * @param menu The menu to work with
116  * @param desktop The desktop to remove
117  * @return Returns 1 on success, 0 on failure
118  * @brief Remove a desktop element in a menu structure. Only accepts desktop files
119  * in default directories.
120  */
121 EAPI int              efreet_menu_desktop_remove(Efreet_Menu *menu,
122                                                     Efreet_Desktop *desktop);
123
124
125 /**
126  * @param menu The menu to work with
127  * @param menu The menu to work with
128  * @param indent The indent level to print the menu at
129  * @return Returns no value
130  * @brief Dumps the contents of the menu to the command line
131  */
132 EAPI void             efreet_menu_dump(Efreet_Menu *menu, const char *indent);
133
134 /**
135  * @}
136  */
137
138 #endif