Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_desktop / Ecore_Desktop.h
1 #ifndef _ECORE_DESKTOP_H
2 # define _ECORE_DESKTOP_H
3
4 #include <Ecore_Data.h>
5 #include <sys/types.h>
6
7 /**
8  * @file Ecore_Desktop.h
9  * @brief The file that provides the freedesktop.org desktop, icon, and menu
10  *        functions.
11  *
12  * This header provides the Ecore_Desktop freedesktop.org desktop, icon, 
13  * and menu handling functions, as well as ancillary functions for searching
14  * freedesktop.org specific paths.  Other freedesktop.org specifications
15  * make use of similar files, paths, and icons, implementors can use / extend
16  * this code to suit.
17  *
18  * Ecore_Desktop is not for every freedesktop.org specification, just those that
19  * are associated with .desktop files.
20  *
21  * For path searching details, see @ref Ecore_Desktop_Paths_Group.
22  *
23  * For desktop file details, see @ref Ecore_Desktop_Main_Group.
24  *
25  * For icon theme details, see @ref Ecore_Desktop_Icon_Group.
26  *
27  * For menu file details, see @ref Ecore_Desktop_Menu_Group.
28  */
29
30 struct _Ecore_Desktop
31 {
32    /* FIXME: Do the ECORE_MAGIC thing here.
33     * While this might help with segfaults and such, I think it's a waste of 
34     * space and cycles that just covers up bugs.  On the other hand, it makes 
35     * for a more robust library, and it's used everywhere else in ecore.
36     */
37    Ecore_Hash         *data, *group, *Categories, *OnlyShowIn, *NotShowIn, *MimeTypes, *Actions;
38    char               *original_path;
39    char               *original_lang;
40    char               *eap_name;
41    char               *name;
42    char               *generic;
43    char               *comment;
44    char               *type;
45    char               *categories;
46    char               *exec;
47    char               *exec_params;
48    char               *icon_class;
49    char               *icon_theme;
50    char               *icon;
51    char               *icon_path;
52    time_t              icon_time;      /* For checking if the icon cache is valid. */
53    char               *path;
54    char               *URL;
55    char               *file;
56    char               *deletiondate;
57    char               *window_class;    /* window class */
58    char               *window_name;     /* window name */
59    char               *window_title;    /* window title */
60    char               *window_role;     /* window role */
61    unsigned char       wait_exit:1;     /* wait for app to exit before execing next */
62    unsigned char       startup:1;
63    unsigned char       hidden:1;
64    unsigned char       no_display:1;
65    unsigned char       allocated:1;
66    unsigned char       ondisk:1;
67    unsigned char       hard_icon:1;
68    /* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
69    time_t              mtime;   /* For checking if the cache is valid. */
70 };
71 typedef struct _Ecore_Desktop Ecore_Desktop;
72
73 struct _Ecore_Desktop_Icon_Theme
74 {
75    Ecore_Hash         *data, *group;
76    Ecore_List         *Inherits;
77    Ecore_List         *Directories;
78    char               *path;
79    char               *name;
80    char               *comment;
81    char               *example;
82    char               *example_path;
83    char               *inherits;
84    char               *directories;
85    int                 hidden;
86    unsigned char       hicolor:1;
87    /* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
88    time_t              mtime;   /* For checking if the cache is valid. */
89    double              last_checked;
90 };
91 typedef struct _Ecore_Desktop_Icon_Theme Ecore_Desktop_Icon_Theme;
92
93 struct _Ecore_Desktop_Icon_Theme_Directory
94 {
95    Ecore_Hash         *icons;
96    char               *path;
97    char               *full_path;
98    char               *type;
99    int                 size, minimum, maximum, threshold;
100 };
101 typedef struct _Ecore_Desktop_Icon_Theme_Directory
102    Ecore_Desktop_Icon_Theme_Directory;
103
104 enum _Ecore_Desktop_Paths_Type
105 {
106    ECORE_DESKTOP_PATHS_CONFIG = 0,
107    ECORE_DESKTOP_PATHS_MENUS = 1,
108    ECORE_DESKTOP_PATHS_DIRECTORIES = 2,
109    ECORE_DESKTOP_PATHS_DESKTOPS = 3,
110    ECORE_DESKTOP_PATHS_ICONS = 4,
111    ECORE_DESKTOP_PATHS_KDE_LEGACY = 5,
112    ECORE_DESKTOP_PATHS_XSESSIONS = 6,
113    ECORE_DESKTOP_PATHS_MAX = 7
114 };
115 typedef enum _Ecore_Desktop_Paths_Type Ecore_Desktop_Paths_Type;
116
117 enum _Ecore_Desktop_Tree_Element_Type
118 {
119    ECORE_DESKTOP_TREE_ELEMENT_TYPE_NULL = 0,
120    ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING = 1,
121    ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE = 2,
122    ECORE_DESKTOP_TREE_ELEMENT_TYPE_HASH = 3
123 };
124 typedef enum _Ecore_Desktop_Tree_Element_Type Ecore_Desktop_Tree_Element_Type;
125
126 struct _Ecore_Desktop_Tree_Element
127 {
128    void               *element; /* A pointer to the element. */
129    Ecore_Desktop_Tree_Element_Type type;        /* The type of the element. */
130 };
131 typedef struct _Ecore_Desktop_Tree_Element Ecore_Desktop_Tree_Element;
132
133 typedef struct _Ecore_Desktop_Tree Ecore_Desktop_Tree;
134 struct _Ecore_Desktop_Tree
135 {
136    Ecore_Desktop_Tree_Element *elements;        /* An array of elements. */
137    int                 size;    /* The size of the array. */
138    char              **buffers; /* An array of pointers to the bits of data. */
139    int                 buffers_size;    /* The size of the array. */
140    Ecore_Desktop_Tree *parent;  /* Parent if this is a child. */
141 };
142
143 struct _Ecore_Desktop_Instrumentation
144 {
145    double desktops_time;
146    double desktops_in_cache_time;
147    double desktops_not_found_time;
148    double icons_time;
149    double icons_in_cache_time;
150    double icons_not_found_time;
151    int desktops;
152    int desktops_in_cache;
153    int desktops_not_found;
154    int icons;
155    int icons_in_cache;
156    int icons_not_found;
157 };
158
159
160 # ifdef __cplusplus
161 extern              "C"
162 {
163 # endif
164
165    /* Function Prototypes */
166    EAPI int            ecore_desktop_paths_init(void);
167    EAPI void           ecore_desktop_paths_extras_clear(void);
168    EAPI void           ecore_desktop_paths_prepend_user(Ecore_Desktop_Paths_Type
169                                                         type, const char *paths);
170    EAPI void          
171       ecore_desktop_paths_prepend_system(Ecore_Desktop_Paths_Type type,
172                                          const char *paths);
173    EAPI void           ecore_desktop_paths_append_user(Ecore_Desktop_Paths_Type
174                                                        type, const char *paths);
175    EAPI void          
176       ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type,
177                                         const char *paths);
178    EAPI void           ecore_desktop_paths_regen(void);
179    char               *ecore_desktop_paths_file_find(Ecore_List * paths,
180                                                      const char *file, int sub,
181                                                      int (*func) (void
182                                                                   *data,
183                                                                   const char
184                                                                   *path),
185                                                      void *data);
186    EAPI int            ecore_desktop_paths_for_each(Ecore_Desktop_Paths_Type
187                                                     type,
188                                                     Ecore_For_Each function,
189                                                     void *user_data);
190    char               *ecore_desktop_paths_recursive_search(const char *path,
191                                                             const char *file,
192                                                             int sub,
193                                                             int (*dir_func)
194                                                             (void *data,
195                                                              const char *path),
196                                                             int (*func) (void
197                                                                          *data,
198                                                                          const
199                                                                          char
200                                                                          *path),
201                                                             void *data);
202    EAPI int            ecore_desktop_paths_shutdown(void);
203
204    Ecore_Hash         *ecore_desktop_paths_to_hash(const char *paths);
205    Ecore_List         *ecore_desktop_paths_to_list(const char *paths);
206
207    EAPI int            ecore_desktop_init(void);
208    EAPI int            ecore_desktop_shutdown(void);
209    Ecore_Hash         *ecore_desktop_ini_get(const char *file);
210    Ecore_Desktop      *ecore_desktop_get(const char *file, const char *lang);
211    void                ecore_desktop_save(Ecore_Desktop * desktop);
212    EAPI Ecore_List    *ecore_desktop_get_command(Ecore_Desktop * desktop,
213                                                  Ecore_List * files, int fill);
214    EAPI char          *ecore_desktop_merge_command(char *exec, char *params);
215    void                ecore_desktop_destroy(Ecore_Desktop * desktop);
216
217    EAPI int            ecore_desktop_icon_init(void);
218    EAPI int            ecore_desktop_icon_shutdown(void);
219    EAPI char          *ecore_desktop_icon_find(const char *icon,
220                                                const char *icon_size,
221                                                const char *icon_theme);
222
223    Ecore_Hash         *ecore_desktop_icon_theme_list(void);
224    Ecore_Desktop_Icon_Theme *ecore_desktop_icon_theme_get(const char *file,
225                                                           const char *lang);
226    void                ecore_desktop_icon_theme_destroy(Ecore_Desktop_Icon_Theme
227                                                         * icon_theme);
228
229    EAPI void          
230       ecore_desktop_menu_for_each(void (*func)
231                                   (const char *name, const char *path, const char *directory, Ecore_Hash * apps));
232    Ecore_Desktop_Tree *ecore_desktop_menu_get(char *file);
233
234    Ecore_Desktop_Tree *ecore_desktop_tree_new(char *buffer);
235    Ecore_Desktop_Tree *ecore_desktop_tree_add(Ecore_Desktop_Tree * tree,
236                                               const char *element);
237    void                ecore_desktop_tree_track(Ecore_Desktop_Tree * tree,
238                                                 void *element);
239    Ecore_Desktop_Tree *ecore_desktop_tree_extend(Ecore_Desktop_Tree * tree,
240                                                  const char *element);
241    Ecore_Desktop_Tree *ecore_desktop_tree_insert(Ecore_Desktop_Tree * tree,
242                                                  int before, void *element,
243                                                  Ecore_Desktop_Tree_Element_Type
244                                                  type);
245    Ecore_Desktop_Tree *ecore_desktop_tree_merge(Ecore_Desktop_Tree * tree,
246                                                 int before,
247                                                 Ecore_Desktop_Tree * element);
248    Ecore_Desktop_Tree *ecore_desktop_tree_add_child(Ecore_Desktop_Tree * tree,
249                                                     Ecore_Desktop_Tree *
250                                                     element);
251    Ecore_Desktop_Tree *ecore_desktop_tree_add_hash(Ecore_Desktop_Tree * tree,
252                                                    Ecore_Hash * element);
253    void                ecore_desktop_tree_remove(Ecore_Desktop_Tree * tree,
254                                                  int element);
255    int                 ecore_desktop_tree_exist(Ecore_Desktop_Tree * tree,
256                                                 char *element);
257    int                 ecore_desktop_tree_foreach(Ecore_Desktop_Tree * tree,
258                                                   int level,
259                                                   int (*func) (const void *data,
260                                                                Ecore_Desktop_Tree
261                                                                * tree,
262                                                                int element,
263                                                                int level),
264                                                   const void *data);
265    void                ecore_desktop_tree_dump(Ecore_Desktop_Tree * tree,
266                                                int level);
267    void                ecore_desktop_tree_del(Ecore_Desktop_Tree * tree);
268
269    Ecore_Desktop_Tree *ecore_desktop_xmlame_new(char *buffer);
270    Ecore_Desktop_Tree *ecore_desktop_xmlame_get(char *file);
271
272    char               *ecore_desktop_home_get(void);
273
274    EAPI void           ecore_desktop_instrumentation_reset(void);
275    EAPI void           ecore_desktop_instrumentation_print(void);
276
277 # ifdef __cplusplus
278 }
279 # endif
280
281 #endif