Tizen 2.1 release
[platform/core/uifw/e17.git] / src / modules / conf_theme / e_int_config_theme_web.c
1 #include "e.h"
2 #include "e_int_config_theme.h"
3 #include "e_int_config_theme_web.h"
4
5 #ifdef HAVE_EXCHANGE
6 #include <Exchange.h>
7
8 typedef struct _Web Web;
9 struct _Web
10 {
11    E_Config_Dialog *parent;
12    E_Dialog        *dia;
13 };
14
15 #if 0
16 static void
17 _web_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
18 {
19    Evas_Coord th, vh;
20
21    evas_object_smart_callback_call(obj, "changed", NULL);
22    evas_object_size_hint_min_get(obj, NULL, &th);
23    evas_object_geometry_get(obj, NULL, NULL, NULL, &vh);
24
25    if (y < 0) y = 0;
26    if (y > th - vh) y = th - vh;
27
28    exchange_smart_object_offset_set(obj, 0, y);
29 }
30
31 static void
32 _web_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
33 {
34    if (!x || !y) return;
35
36    exchange_smart_object_offset_get(obj, x, y);
37 }
38
39 static void
40 _web_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
41 {
42    Evas_Coord tw, th, vw, vh;
43
44    evas_object_size_hint_min_get(obj, &tw, &th);
45    evas_object_geometry_get(obj, NULL, NULL, &vw, &vh);
46
47    if (x) *x = tw - vw;
48    if (y) *y = th - vh;
49 }
50
51 static void
52 _web_pan_child_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
53 {
54    Evas_Coord tw, th, vw, vh;
55
56    evas_object_size_hint_min_get(obj, &tw, &th);
57    evas_object_geometry_get(obj, NULL, NULL, &vw, &vh);
58
59    if (x) *x = tw;
60    if (y) *y = th;
61 }
62
63 void
64 e_int_config_theme_web_del(E_Dialog *dia)
65 {
66    Web *web;
67
68    web = dia->data;
69    e_int_config_theme_web_done(web->parent);
70    E_FREE(web);
71    e_object_unref(E_OBJECT(dia));
72 }
73
74 static void
75 _web_del_cb(void *obj)
76 {
77    E_Dialog *dia = obj;
78
79    e_int_config_theme_web_del(dia);
80 }
81
82 static void
83 _web_close_cb(void *data, E_Dialog *dia)
84 {
85    e_int_config_theme_web_del(dia);
86 }
87
88 static void
89 _web_apply(const char *path, void *data)
90 {
91    E_Action *a;
92    E_Config_Theme *ct;
93
94    ct = e_theme_config_get("theme");
95    if ((ct) && (!strcmp(ct->file, path))) return;
96
97    e_theme_config_set("theme", path);
98    e_config_save_queue();
99
100    a = e_action_find("restart");
101    if ((a) && (a->func.go)) a->func.go(NULL, NULL);
102 }
103
104 #endif
105
106 E_Dialog *
107 e_int_config_theme_web(E_Config_Dialog *parent)
108 {
109 #if 0
110    E_Dialog *dia;
111    Web *web;
112    Evas_Object *ol, *exsm, *sf;
113    Evas_Coord mw, mh;
114    E_Fm2_Config fmc;
115    char usr_dir[PATH_MAX];
116
117    dia = e_dialog_new(parent->con, "E", "_theme_web_dialog");
118    if (!dia) return NULL;
119
120    web = E_NEW(Web, 1);
121    if (!web) return NULL;
122
123    web->dia = dia;
124    web->parent = parent;
125
126    e_dialog_title_set(dia, _("Exchange themes"));
127    e_dialog_border_icon_set(dia, "enlightenment/theme");
128    e_dialog_resizable_set(dia, 1);
129    e_dialog_button_add(dia, _("Close"), NULL, _web_close_cb, web);
130
131    dia->data = web;
132    e_object_del_attach_func_set(E_OBJECT(dia), _web_del_cb);
133    e_win_centered_set(dia->win, 1);
134
135    ol = e_widget_list_add(e_win_evas_get(dia->win), 0, 1);
136
137    // The Exchange Smart Object
138    e_user_dir_concat_static(usr_dir, "themes");
139    exsm = exchange_smart_object_add(e_win_evas_get(dia->win));
140    exchange_smart_object_remote_group_set(exsm, "Border");
141    exchange_smart_object_local_path_set(exsm, usr_dir);
142    exchange_smart_object_apply_cb_set(exsm, _web_apply, NULL);
143
144    // The Scroll Frame
145    sf = e_scrollframe_add(e_win_evas_get(dia->win));
146    e_scrollframe_extern_pan_set(sf, exsm, _web_pan_set, _web_pan_get,
147                                 _web_pan_max_get, _web_pan_child_size_get);
148    e_scrollframe_policy_set(sf, E_SCROLLFRAME_POLICY_OFF,
149                             E_SCROLLFRAME_POLICY_ON);
150    e_scrollframe_thumbscroll_force(sf, 1);
151
152    e_widget_list_object_append(ol, sf, 1, 1, 0.5);
153    e_dialog_content_set(dia, ol, 500, 400);
154
155    e_dialog_show(dia);
156    exchange_smart_object_run(exsm);
157
158    return dia;
159 #endif
160    return NULL;
161 }
162
163 #endif