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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
/* local function prototypes */
static void *_il_home_config_create(E_Config_Dialog *cfd);
static void _il_home_config_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_il_home_config_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void _il_home_config_changed(void *data, Evas_Object *obj, void *event);
static void _il_home_config_slider_changed(void *data, Evas_Object *obj);
static void _il_home_config_click_changed(void *data, Evas_Object *obj, void *event);
static Eina_Bool _il_home_config_change_timeout(void *data);
/* local variables */
EAPI Il_Home_Config *il_home_cfg = NULL;
static E_Config_DD *conf_edd = NULL;
Ecore_Timer *_il_home_config_change_timer = NULL;
Evas_Object *delay_label, *delay_slider;
/* public functions */
int
il_home_config_init(E_Module *m)
{
char buff[PATH_MAX];
conf_edd = E_CONFIG_DD_NEW("Illume-Home_Cfg", Il_Home_Config);
#undef T
#undef D
#define T Il_Home_Config
#define D conf_edd
E_CONFIG_VAL(D, T, version, INT);
E_CONFIG_VAL(D, T, icon_size, INT);
E_CONFIG_VAL(D, T, single_click, INT);
E_CONFIG_VAL(D, T, single_click_delay, INT);
il_home_cfg = e_config_domain_load("module.illume-home", conf_edd);
if ((il_home_cfg) &&
((il_home_cfg->version >> 16) < IL_CONFIG_MAJ))
{
E_FREE(il_home_cfg);
il_home_cfg = NULL;
}
if (!il_home_cfg)
{
il_home_cfg = E_NEW(Il_Home_Config, 1);
il_home_cfg->version = 0;
il_home_cfg->icon_size = 120;
il_home_cfg->single_click = 1;
il_home_cfg->single_click_delay = 50;
}
if (il_home_cfg)
{
/* Add new config variables here */
/* if ((il_home_cfg->version & 0xffff) < 1) */
il_home_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN;
}
il_home_cfg->mod_dir = eina_stringshare_add(m->dir);
snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj",
il_home_cfg->mod_dir);
e_configure_registry_category_add("illume", 0, _("Illume"), NULL,
"enlightenment/display");
e_configure_registry_generic_item_add("illume/home", 0, _("Home"),
buff, "icon", il_home_config_show);
return 1;
}
int
il_home_config_shutdown(void)
{
il_home_cfg->cfd = NULL;
e_configure_registry_item_del("illume/home");
e_configure_registry_category_del("illume");
if (il_home_cfg->mod_dir) eina_stringshare_del(il_home_cfg->mod_dir);
E_FREE(il_home_cfg);
il_home_cfg = NULL;
E_CONFIG_DD_FREE(conf_edd);
return 1;
}
int
il_home_config_save(void)
{
e_config_domain_save("module.illume-home", conf_edd, il_home_cfg);
return 1;
}
void
il_home_config_show(E_Comp *comp, const char *params EINA_UNUSED)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v = NULL;
if (e_config_dialog_find("E", "_config_illume_home_settings")) return;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _il_home_config_create;
v->free_cfdata = _il_home_config_free;
v->basic.create_widgets = _il_home_config_ui;
v->basic_only = 1;
v->normal_win = 1;
v->scroll = 1;
cfd = e_config_dialog_new(NULL, _("Home Settings"), "E",
"_config_illume_home_settings",
"enlightenment/launcher_settings", 0, v, NULL);
il_home_cfg->cfd = cfd;
}
/* local functions */
static void *
_il_home_config_create(E_Config_Dialog *cfd EINA_UNUSED)
{
return NULL;
}
static void
_il_home_config_free(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
il_home_cfg->cfd = NULL;
il_home_win_cfg_update();
}
static Evas_Object *
_il_home_config_ui(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
Evas_Object *list, *of, *o;
E_Radio_Group *rg;
list = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("Icon Size"), 0);
rg = e_widget_radio_group_new(&(il_home_cfg->icon_size));
o = e_widget_radio_add(evas, _("Small"), 60, rg);
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
o = e_widget_radio_add(evas, _("Medium"), 80, rg);
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
o = e_widget_radio_add(evas, _("Large"), 120, rg);
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
o = e_widget_radio_add(evas, _("Very Large"), 160, rg);
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
o = e_widget_radio_add(evas, _("Massive"), 240, rg);
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
e_widget_list_object_append(list, of, 1, 0, 0.0);
of = e_widget_framelist_add(evas, _("Launch Action"), 0);
o = e_widget_check_add(evas, _("Single press"),
&(il_home_cfg->single_click));
e_widget_framelist_object_append(of, o);
evas_object_smart_callback_add(o, "changed",
_il_home_config_click_changed, NULL);
o = e_widget_label_add(evas, _("Press Delay"));
delay_label = o;
e_widget_disabled_set(o, !(il_home_cfg->single_click));
e_widget_framelist_object_append(of, o);
o = e_widget_slider_add(evas, 1, 0, "%1.0f ms", 0, 350, 1, 0, NULL,
&(il_home_cfg->single_click_delay), 150);
delay_slider = o;
e_widget_on_change_hook_set(o, _il_home_config_slider_changed, NULL);
e_widget_disabled_set(o, !(il_home_cfg->single_click));
e_widget_framelist_object_append(of, o);
e_widget_list_object_append(list, of, 1, 0, 0.0);
return list;
}
static void
_il_home_config_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
if (_il_home_config_change_timer)
ecore_timer_del(_il_home_config_change_timer);
_il_home_config_change_timer =
ecore_timer_add(0.5, _il_home_config_change_timeout, data);
}
static void
_il_home_config_slider_changed(void *data, Evas_Object *obj EINA_UNUSED)
{
if (_il_home_config_change_timer)
ecore_timer_del(_il_home_config_change_timer);
_il_home_config_change_timer =
ecore_timer_add(0.5, _il_home_config_change_timeout, data);
}
static void
_il_home_config_click_changed(void *data, Evas_Object *obj, void *event)
{
e_widget_disabled_set(delay_label, !il_home_cfg->single_click);
e_widget_disabled_set(delay_slider, !il_home_cfg->single_click);
_il_home_config_changed(data, obj, event);
}
static Eina_Bool
_il_home_config_change_timeout(void *data EINA_UNUSED)
{
il_home_win_cfg_update();
e_config_save_queue();
_il_home_config_change_timer = NULL;
return ECORE_CALLBACK_CANCEL;
}
|