Git init
[platform/core/uifw/e17.git] / src / modules / illume-home / e_busycover.c
1 #include "e.h"
2 #include "e_busycover.h"
3 #include "e_mod_config.h"
4
5 /* local function prototypes */
6 static void _e_busycover_cb_free(E_Busycover *cover);
7
8 EAPI E_Busycover *
9 e_busycover_new(E_Win *win) 
10 {
11    E_Busycover *cover;
12    char buff[PATH_MAX];
13
14    cover = E_OBJECT_ALLOC(E_Busycover, E_BUSYCOVER_TYPE, _e_busycover_cb_free);
15    if (!cover) return NULL;
16    snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj", 
17             il_home_cfg->mod_dir);
18
19    cover->o_base = edje_object_add(e_win_evas_get(win));
20    if (!e_theme_edje_object_set(cover->o_base, 
21                                 "base/theme/modules/illume-home", 
22                                 "modules/illume-home/busycover")) 
23      edje_object_file_set(cover->o_base, buff, "modules/illume-home/busycover");
24    edje_object_part_text_set(cover->o_base, "e.text.title", _("LOADING"));
25    evas_object_move(cover->o_base, win->x, win->y);
26    evas_object_resize(cover->o_base, win->w, win->h);
27    evas_object_layer_set(cover->o_base, 999);
28    return cover;
29 }
30
31 EAPI E_Busycover_Handle *
32 e_busycover_push(E_Busycover *cover, const char *msg, const char *icon) 
33 {
34    E_Busycover_Handle *handle;
35
36    E_OBJECT_CHECK(cover);
37    E_OBJECT_TYPE_CHECK_RETURN(cover, E_BUSYCOVER_TYPE, NULL);
38
39    handle = E_NEW(E_Busycover_Handle, 1);
40    handle->cover = cover;
41    if (msg) handle->msg = eina_stringshare_add(msg);
42    if (icon) handle->icon = eina_stringshare_add(icon);
43    cover->handles = eina_list_append(cover->handles, handle);
44    edje_object_part_text_set(cover->o_base, "e.text.title", msg);
45    evas_object_show(cover->o_base);
46    return handle;
47 }
48
49 EAPI void 
50 e_busycover_pop(E_Busycover *cover, E_Busycover_Handle *handle) 
51 {
52    E_OBJECT_CHECK(cover);
53    E_OBJECT_TYPE_CHECK(cover, E_BUSYCOVER_TYPE);
54    if (!eina_list_data_find(cover->handles, handle)) return;
55    cover->handles = eina_list_remove(cover->handles, handle);
56    if (handle->msg) eina_stringshare_del(handle->msg);
57    if (handle->icon) eina_stringshare_del(handle->icon);
58    E_FREE(handle);
59    if (cover->handles) 
60      {
61         handle = cover->handles->data;
62         edje_object_part_text_set(cover->o_base, "e.text.title", handle->msg);
63      }
64    else 
65      evas_object_hide(cover->o_base);
66 }
67
68 EAPI void 
69 e_busycover_resize(E_Busycover *cover, int w, int h) 
70 {
71    E_OBJECT_CHECK(cover);
72    E_OBJECT_TYPE_CHECK(cover, E_BUSYCOVER_TYPE);
73    evas_object_resize(cover->o_base, w, h);
74 }
75
76 /* local function prototypes */
77 static void 
78 _e_busycover_cb_free(E_Busycover *cover) 
79 {
80    E_Busycover_Handle *handle;
81
82    EINA_LIST_FREE(cover->handles, handle) 
83      {
84         if (handle->msg) eina_stringshare_del(handle->msg);
85         if (handle->icon) eina_stringshare_del(handle->icon);
86         E_FREE(handle);
87      }
88
89    if (cover->o_base) evas_object_del(cover->o_base);
90    E_FREE(cover);
91 }