disable factory for elm release
[framework/uifw/elementary.git] / src / lib / elm_store.h
1 // XXX: need docs!
2 typedef struct _Elm_Store                      Elm_Store;
3 typedef struct _Elm_Store_Filesystem           Elm_Store_Filesystem;
4 typedef struct _Elm_Store_Item                 Elm_Store_Item;
5 typedef struct _Elm_Store_Item_Filesystem      Elm_Store_Item_Filesystem;
6 typedef struct _Elm_Store_Item_Info            Elm_Store_Item_Info;
7 typedef struct _Elm_Store_Item_Info_Filesystem Elm_Store_Item_Info_Filesystem;
8 typedef struct _Elm_Store_Item_Mapping         Elm_Store_Item_Mapping;
9 typedef struct _Elm_Store_Item_Mapping_Empty   Elm_Store_Item_Mapping_Empty;
10 typedef struct _Elm_Store_Item_Mapping_Icon    Elm_Store_Item_Mapping_Icon;
11 typedef struct _Elm_Store_Item_Mapping_Photo   Elm_Store_Item_Mapping_Photo;
12 typedef struct _Elm_Store_Item_Mapping_Custom  Elm_Store_Item_Mapping_Custom;
13
14 typedef Eina_Bool                            (*Elm_Store_Item_List_Cb)(void *data, Elm_Store_Item_Info *info);
15 typedef void                                 (*Elm_Store_Item_Fetch_Cb)(void *data, Elm_Store_Item *sti);
16 typedef void                                 (*Elm_Store_Item_Unfetch_Cb)(void *data, Elm_Store_Item *sti);
17 typedef void                                *(*Elm_Store_Item_Mapping_Cb)(void *data, Elm_Store_Item *sti, const char *part);
18
19 typedef enum
20 {
21    ELM_STORE_ITEM_MAPPING_NONE = 0,
22    ELM_STORE_ITEM_MAPPING_LABEL, // const char * -> label
23    ELM_STORE_ITEM_MAPPING_STATE, // Eina_Bool -> state
24    ELM_STORE_ITEM_MAPPING_ICON, // char * -> icon path
25    ELM_STORE_ITEM_MAPPING_PHOTO, // char * -> photo path
26    ELM_STORE_ITEM_MAPPING_CUSTOM, // item->custom(it->data, it, part) -> void * (-> any)
27    // can add more here as needed by common apps
28    ELM_STORE_ITEM_MAPPING_LAST
29 } Elm_Store_Item_Mapping_Type;
30
31 struct _Elm_Store_Item_Mapping_Icon
32 {
33    // FIXME: allow edje file icons
34    int                   w, h;
35    Elm_Icon_Lookup_Order lookup_order;
36    Eina_Bool             standard_name : 1;
37    Eina_Bool             no_scale : 1;
38    Eina_Bool             smooth : 1;
39    Eina_Bool             scale_up : 1;
40    Eina_Bool             scale_down : 1;
41 };
42
43 struct _Elm_Store_Item_Mapping_Empty
44 {
45    Eina_Bool dummy;
46 };
47
48 struct _Elm_Store_Item_Mapping_Photo
49 {
50    int size;
51 };
52
53 struct _Elm_Store_Item_Mapping_Custom
54 {
55    Elm_Store_Item_Mapping_Cb func;
56 };
57
58 struct _Elm_Store_Item_Mapping
59 {
60    Elm_Store_Item_Mapping_Type type;
61    const char                 *part;
62    int                         offset;
63    union
64    {
65       Elm_Store_Item_Mapping_Empty  empty;
66       Elm_Store_Item_Mapping_Icon   icon;
67       Elm_Store_Item_Mapping_Photo  photo;
68       Elm_Store_Item_Mapping_Custom custom;
69       // add more types here
70    } details;
71 };
72
73 struct _Elm_Store_Item_Info
74 {
75    Elm_Genlist_Item_Class       *item_class;
76    const Elm_Store_Item_Mapping *mapping;
77    void                         *data;
78    char                         *sort_id;
79 };
80
81 struct _Elm_Store_Item_Info_Filesystem
82 {
83    Elm_Store_Item_Info base;
84    char               *path;
85 };
86
87 #define ELM_STORE_ITEM_MAPPING_END { ELM_STORE_ITEM_MAPPING_NONE, NULL, 0, { .empty = { EINA_TRUE } } }
88 #define ELM_STORE_ITEM_MAPPING_OFFSET(st, it) offsetof(st, it)
89
90 EAPI void                    elm_store_free(Elm_Store *st);
91
92 EAPI Elm_Store              *elm_store_filesystem_new(void);
93 EAPI void                    elm_store_filesystem_directory_set(Elm_Store *st, const char *dir);
94 EAPI const char             *elm_store_filesystem_directory_get(const Elm_Store *st);
95 EAPI const char             *elm_store_item_filesystem_path_get(const Elm_Store_Item *sti);
96
97 EAPI void                    elm_store_target_genlist_set(Elm_Store *st, Evas_Object *obj);
98
99 EAPI void                    elm_store_cache_set(Elm_Store *st, int max);
100 EAPI int                     elm_store_cache_get(const Elm_Store *st);
101 EAPI void                    elm_store_list_func_set(Elm_Store *st, Elm_Store_Item_List_Cb func, const void *data);
102 EAPI void                    elm_store_fetch_func_set(Elm_Store *st, Elm_Store_Item_Fetch_Cb func, const void *data);
103 EAPI void                    elm_store_fetch_thread_set(Elm_Store *st, Eina_Bool use_thread);
104 EAPI Eina_Bool               elm_store_fetch_thread_get(const Elm_Store *st);
105
106 EAPI void                    elm_store_unfetch_func_set(Elm_Store *st, Elm_Store_Item_Unfetch_Cb func, const void *data);
107 EAPI void                    elm_store_sorted_set(Elm_Store *st, Eina_Bool sorted);
108 EAPI Eina_Bool               elm_store_sorted_get(const Elm_Store *st);
109 EAPI void                    elm_store_item_data_set(Elm_Store_Item *sti, void *data);
110 EAPI void                   *elm_store_item_data_get(Elm_Store_Item *sti);
111 EAPI const Elm_Store        *elm_store_item_store_get(const Elm_Store_Item *sti);
112 EAPI const Elm_Object_Item *elm_store_item_genlist_item_get(const Elm_Store_Item *sti);