aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/efreet/efreet_menu.h
blob: de852199aee429cd6a5a88c95564e8eaca0d31b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef EFREET_MENU_H
#define EFREET_MENU_H

/**
 * @file efreet_menu.h
 * @brief Contains the structures and methods to support the Desktop
 * Menu Specification.
 *
 * @internal
 * @defgroup Efreet_Menu_Group Efreet_Menu: The FDO Desktop Menu Specification
 *           functions and structures
 * @ingroup Efreet_Group
 *
 * @{
 */

/**
 * The type of entry
 */
typedef enum Efreet_Menu_Entry_Type
{
    EFREET_MENU_ENTRY_MENU,
    EFREET_MENU_ENTRY_DESKTOP,
    EFREET_MENU_ENTRY_SEPARATOR,
    EFREET_MENU_ENTRY_HEADER
} Efreet_Menu_Entry_Type;

/**
 * Efreet_Menu
 */
typedef struct Efreet_Menu Efreet_Menu;

/**
 * Efreet_Menu
 * Stores information on a entry in the menu
 */
struct Efreet_Menu
{
    Efreet_Menu_Entry_Type type;
    const char *id;   /**< File-id for desktop and relative name for menu */

    const char *name; /**< Name this entry should show */
    const char *icon; /**< Icon for this entry */

    Efreet_Desktop *desktop;   /**< The desktop we refer too */
    Eina_List      *entries;   /**< The menu items */
};


/**
 * @brief Initialize legacy kde support. This function blocks while
 * the kde-config script is run.
 *
 * @return Returns no value
 */
EAPI int              efreet_menu_kde_legacy_init(void);

/**
 * @brief Creates a new menu
 *
 * @param[in] name The internal name of the menu
 * @return Returns the Efreet_Menu on success or
 * NULL on failure
 */
EAPI Efreet_Menu     *efreet_menu_new(const char *name);

/**
 * @brief Override which file is used for menu creation
 *
 * @param[in] file The file to use for menu creation
 *
 * This file is only used if it exists, else the standard files will be used
 * for the menu.
 */
EAPI void             efreet_menu_file_set(const char *file);

/**
 * @brief Creates the default menu representation
 *
 * @return Returns the Efreet_Menu_Internal representation of the default menu or
 * NULL if none found
 */
EAPI Efreet_Menu     *efreet_menu_get(void);

/**
 * @brief Parses the given .menu file and creates the menu representation
 *
 * @param[in] path The path of the menu to load
 * @return Returns the Efreet_Menu_Internal representation on success or NULL on
 * failure
 */
EAPI Efreet_Menu     *efreet_menu_parse(const char *path);

/**
 * @brief Saves the menu to file
 *
 * @param[in] menu The menu to work with
 * @param[in] path The path where the menu should be saved
 * @return Returns 1 on success, 0 on failure
 */
EAPI int              efreet_menu_save(Efreet_Menu *menu, const char *path);

/**
 * @brief Frees the given structure
 *
 * @param[in] menu The Efreet_Menu to free
 * @return Returns no value
 */
EAPI void             efreet_menu_free(Efreet_Menu *menu);


/**
 * @brief Insert a desktop element in a menu structure. Only accepts desktop files
 * in default directories.
 *
 * @param[in] menu The menu to work with
 * @param[in] desktop The desktop to insert
 * @param[in] pos The position to place the new desktop
 * @return Returns 1 on success, 0 on failure
 */
EAPI int              efreet_menu_desktop_insert(Efreet_Menu *menu,
                                                    Efreet_Desktop *desktop,
                                                    int pos);

/**
 * @brief Remove a desktop element in a menu structure. Only accepts desktop files
 * in default directories.
 *
 * @param[in] menu The menu to work with
 * @param[in] desktop The desktop to remove
 * @return Returns 1 on success, 0 on failure
 */
EAPI int              efreet_menu_desktop_remove(Efreet_Menu *menu,
                                                    Efreet_Desktop *desktop);


/**
 * @brief Dumps the contents of the menu to the command line
 *
 * @param[in] menu The menu to work with
 * @param[in] menu The menu to work with
 * @param[in] indent The indent level to print the menu at
 * @return Returns no value
 */
EAPI void             efreet_menu_dump(Efreet_Menu *menu, const char *indent);

/**
 * @}
 */

#endif