summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2005-12-22 22:40:21 +0000
committerChristopher Michael <cpmichael1@comcast.net>2005-12-22 22:40:21 +0000
commitbaa9fae93077a730dcb61651f53b86820490183e (patch)
tree289615ad3e1285d9a2b2751b68a4cea07e6c0542
parentf33c45d144ccbeb6b7ad3c8be37f092d4c213f8e (diff)
Rewrite e_int_config_modules.c.
This fixes the segfault issues people were having. Recommend resyncing your E codebase with current cvs as this uses newer e_widget_ilist functions that I committed earlier. SVN revision: 19248
-rw-r--r--src/bin/e_int_config_modules.c596
1 files changed, 312 insertions, 284 deletions
diff --git a/src/bin/e_int_config_modules.c b/src/bin/e_int_config_modules.c
index efeea30a7..cf4299210 100644
--- a/src/bin/e_int_config_modules.c
+++ b/src/bin/e_int_config_modules.c
@@ -2,10 +2,10 @@
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */ 3 */
4#include "e.h" 4#include "e.h"
5 5
6/* PROTOTYPES - same all the time */ 6/* PROTOTYPES - same all the time */
7typedef struct _CFData CFData; 7typedef struct _CFData CFData;
8typedef struct _E_Cfg_Mod_Data E_Cfg_Mod_Data; 8typedef struct _E_Widget_Data E_Widget_Data;
9 9
10static void *_create_data(E_Config_Dialog *cfd); 10static void *_create_data(E_Config_Dialog *cfd);
11static void _free_data(E_Config_Dialog *cfd, CFData *cfdata); 11static void _free_data(E_Config_Dialog *cfd, CFData *cfdata);
@@ -14,37 +14,28 @@ static int _advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata);
14static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata); 14static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
15static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata); 15static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
16 16
17static void _e_config_module_list(Evas_List **b,char *dir, int loaded); 17static void _ilist_cb_change(void *data, Evas_Object *obj);
18static void _e_config_mod_cb_standard(void *data); 18static void _ilist2_cb_change(void *data, Evas_Object *obj);
19
19static void _module_load(void *data, void *data2); 20static void _module_load(void *data, void *data2);
20static void _module_unload(void *data, void *data2); 21static void _module_unload(void *data, void *data2);
21static void _module_enable(void *data, void *data2); 22static void _module_enable(void *data, void *data2);
23static void _module_disable(void *data, void *data2);
22static void _module_configure(void *data, void *data2); 24static void _module_configure(void *data, void *data2);
23static void _module_about(void *data, void *data2); 25static void _module_about(void *data, void *data2);
24 26
27//static CFData cdata = NULL;
28
25/* Actual config data we will be playing with whil the dialog is active */ 29/* Actual config data we will be playing with whil the dialog is active */
26struct _CFData 30struct _CFData
27{ 31{
28 /*- BASIC -*/ 32 E_Config_Dialog *cfd;
29 int mode;
30 /*- ADVANCED -*/
31 Evas_List *mods, *umods;
32 E_Module *cur_mod;
33 Evas_Object *mod_name;
34 struct { 33 struct {
35 Evas_Object *configure, *enable, *disable, *about; 34 Evas_Object *configure, *enable, *disable, *about;
36 Evas_Object *load, *unload, *loaded, *unloaded; 35 Evas_Object *load, *unload, *loaded, *unloaded;
37 } gui; 36 } gui;
38}; 37};
39 38
40struct _E_Cfg_Mod_Data
41{
42 E_Config_Dialog *cfd;
43 int loaded;
44 E_Module *mod;
45 char *mod_name;// use this for unloaded mods
46};
47
48/* a nice easy setup function that does the dirty work */ 39/* a nice easy setup function that does the dirty work */
49E_Config_Dialog * 40E_Config_Dialog *
50e_int_config_modules(E_Container *con) 41e_int_config_modules(E_Container *con)
@@ -60,222 +51,162 @@ e_int_config_modules(E_Container *con)
60 v.advanced.apply_cfdata = _advanced_apply_data; 51 v.advanced.apply_cfdata = _advanced_apply_data;
61 v.advanced.create_widgets = _advanced_create_widgets; 52 v.advanced.create_widgets = _advanced_create_widgets;
62 /* create config diaolg for NULL object/data */ 53 /* create config diaolg for NULL object/data */
63 cfd = e_config_dialog_new(con, _("Modules Settings"), NULL, 0, &v, NULL); 54 cfd = e_config_dialog_new(con, _("Module Settings"), NULL, 0, &v, NULL);
64 return cfd; 55 return cfd;
65} 56}
66 57
67/* FIXME : redo this to setup list of loaded and unloaded modules in one pass (easy):)*/ 58static void
68/* FIXME: this leaks ecore list of files - also same fn dealing with 2 lists is a bit evil */ 59_module_load(void *data, void *data2)
69static void
70_e_config_module_list(Evas_List **b, char *dir, int loaded)
71{ 60{
72 Evas_List *l; 61 Evas_Object *ilist2;
73 char fullpath[PATH_MAX]; 62 CFData *cfdata;
63 E_Module *m;
64 int i;
65 char *v;
74 66
75 l = *b; 67 ilist2 = data;
76 if ((ecore_file_exists(dir)) && (ecore_file_is_dir(dir))) 68 cfdata = data2;
77 { 69 i = e_widget_ilist_selected_get(ilist2);
78 Ecore_List *mods; 70 v = strdup(e_widget_ilist_selected_label_get(ilist2));
79 71 m = e_module_find(v);
80 mods = ecore_file_ls(dir); 72 if (!m)
81 if (mods) 73 {
82 { 74 m = e_module_new(v);
83 char *mod; 75 cfdata->cfd->view_dirty = 1;
84 int i = 0;
85
86 while ((mod = ecore_list_next(mods)))
87 {
88 snprintf(fullpath, sizeof(fullpath), "%s/%s", dir, mod);
89 if (ecore_file_is_dir(fullpath))
90 {
91 E_Module *m;
92
93 m = e_module_find(mod);
94 if ((!m) && (!loaded))
95 l = evas_list_append(l, mod);
96 else if ((m) && (loaded))
97 l = evas_list_append(l, m);
98 }
99 }
100 }
101 } 76 }
102 *b = l;
103} 77}
104 78
105static void 79static void
106_e_config_mod_cb_standard(void *data) 80_module_unload(void *data, void *data2)
107{ 81{
108 E_Cfg_Mod_Data *d; 82 Evas_Object *ilist;
109 E_Config_Dialog *cfd;
110 CFData *cfdata; 83 CFData *cfdata;
111 E_Module *m; 84 E_Module *m;
85 int i;
86 char *v;
112 87
113 d = data; 88 ilist = data;
114 cfd = d->cfd; 89 cfdata = data2;
115 cfdata = cfd->cfdata;
116
117 m = d->mod;
118 cfd->data = m;
119 90
120 if (m->enabled) 91 i = e_widget_ilist_selected_get(ilist);
121 { 92 v = strdup(e_widget_ilist_selected_label_get(ilist));
122 e_widget_disabled_set(cfdata->gui.enable, 1); 93 m = e_module_find(v);
123 e_widget_disabled_set(cfdata->gui.disable, 0); 94 if (m)
124 if (m->func.config) 95 {
125 e_widget_disabled_set(cfdata->gui.configure, 0); 96 e_module_disable(m);
126 else 97 e_object_del(E_OBJECT(m));
127 e_widget_disabled_set(cfdata->gui.configure, 1); 98 e_config_save_queue();
128 } 99 cfdata->cfd->view_dirty = 1;
129 else
130 {
131 e_widget_disabled_set(cfdata->gui.configure, 1);
132 e_widget_disabled_set(cfdata->gui.enable, 0);
133 e_widget_disabled_set(cfdata->gui.disable, 1);
134 }
135
136 if (m->func.about)
137 e_widget_disabled_set(cfdata->gui.about, 0);
138 else
139 e_widget_disabled_set(cfdata->gui.about, 1);
140
141 /* Load / Unload menu */
142 if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED)
143 {
144 if (!d->loaded)/* unloaded module was clicked */
145 {
146 cfd->data=d->mod_name;
147 e_widget_disabled_set(cfdata->gui.load, 0);
148 e_widget_disabled_set(cfdata->gui.unload, 1);
149 e_widget_disabled_set(cfdata->gui.loaded, 1);
150 }
151 else /* this is a loaded module */
152 {
153 cfd->data=d->mod;
154 e_widget_disabled_set(cfdata->gui.load, 1);
155 e_widget_disabled_set(cfdata->gui.unload, 0);
156 }
157 } 100 }
158} 101}
159 102
160static void 103static void
161_module_load(void *data, void *data2) 104_module_enable(void *data, void *data2) /* this enables and disables :) */
162{ 105{
163 E_Cfg_Mod_Data *d; 106 Evas_Object *obj;
164 E_Config_Dialog *cfd;
165 CFData *cfdata; 107 CFData *cfdata;
166 Evas_Object *ob; 108 E_Module *m;
109 int i;
110 char *v;
167 111
168 cfd = data; 112 obj = data;
169 d = cfd->data; 113 cfdata = data2;
170 cfdata = cfd->cfdata;
171 e_module_new(d->mod_name);
172 114
173 cfd->view_dirty = 1; 115 i = e_widget_ilist_selected_get(obj);
174} 116 v = strdup(e_widget_ilist_selected_label_get(obj));
175 117 m = e_module_find(v);
176static void 118 if (!m)
177_module_unload(void *data, void *data2) 119 {
178{ 120 m = e_module_new(v);
179 E_Cfg_Mod_Data *d; 121 }
180 E_Module *m;
181 E_Config_Dialog *cfd;
182 CFData *cfdata;
183 122
184 cfd = data; 123 if (!m->enabled)
185 d = cfd->data; 124 {
186 m = d->mod; 125 e_module_enable(m);
187 cfdata = cfd->cfdata; 126 if (m->func.config)
188 127 {
189 e_module_disable(m); 128 e_widget_disabled_set(cfdata->gui.configure, 0);
190 e_object_del(E_OBJECT(m)); 129 }
191 e_config_save_queue(); 130 e_widget_disabled_set(cfdata->gui.enable, 1);
192 cfd->view_dirty = 1; 131 e_widget_disabled_set(cfdata->gui.disable, 0);
132 }
133 cfdata->cfd->view_dirty = 1;
193} 134}
194 135
195static void 136static void
196_module_enable(void *data, void *data2) /* this enables and disables :) */ 137_module_disable(void *data, void *data2) /* this enables and disables :) */
197{ 138{
198 E_Config_Dialog *cfd; 139 Evas_Object *obj;
199 CFData *cfdata; 140 CFData *cfdata;
200 E_Module *m; 141 E_Module *m;
201 E_Cfg_Mod_Data *d; 142 int i;
143 char *v;
202 144
203 cfd = data; 145 obj = data;
204 d = cfd->data; 146 cfdata = data2;
205 147
206 if (!d->loaded) 148 i = e_widget_ilist_selected_get(obj);
149 v = strdup(e_widget_ilist_selected_label_get(obj));
150 m = e_module_find(v);
151 if (m)
207 { 152 {
208 m = e_module_new(d->mod_name); 153 if (m->enabled)
209 cfd->view_dirty = 1; 154 {
210 } 155 e_module_save(m);
211 else 156 e_module_disable(m);
212 { 157 cfdata->cfd->view_dirty = 1;
213 m = d->mod; 158 }
214 } 159 }
215 cfdata = cfd->cfdata;
216
217 if (m->enabled)
218 {
219 e_module_save(m);
220 e_module_disable(m);
221
222 e_widget_disabled_set(cfdata->gui.configure, 1);
223 e_widget_disabled_set(cfdata->gui.enable, 0);
224 e_widget_disabled_set(cfdata->gui.disable, 1);
225 }
226 else
227 {
228 e_module_enable(m);
229 if (m->func.config)
230 e_widget_disabled_set(cfdata->gui.configure, 0);
231 e_widget_disabled_set(cfdata->gui.enable, 1);
232 e_widget_disabled_set(cfdata->gui.disable, 0);
233 }
234
235 /* this forces a redraw of the window so that the buttons update their
236 * state properly... probably fix this with a better method that doesn't
237 * unselect the current selection
238 */
239 cfd->view_dirty = 1;
240} 160}
241 161
242static void 162static void
243_module_configure(void *data, void *data2) 163_module_configure(void *data, void *data2)
244{ 164{
245 E_Cfg_Mod_Data *d; 165 Evas_Object *obj;
246 E_Config_Dialog *cfd;
247 CFData *cfdata;
248 E_Module *m; 166 E_Module *m;
167 int i;
168 char *v;
249 169
250 cfd = data; 170 obj = data;
251 m = cfd->data; 171 i = e_widget_ilist_selected_get(obj);
252// d = cfd->data; 172 v = strdup(e_widget_ilist_selected_label_get(obj));
253// m = d->mod; 173 m = e_module_find(v);
254 cfdata = cfd->cfdata; 174 if (m)
255 if (m->func.config) 175 {
256 { 176 if (m->func.config)
257 m->func.config(m); 177 {
178 m->func.config(m);
179 }
180 else
181 {
182 printf("Can't run config no module!!!\n");// Debug!!
183 }
258 } 184 }
259 else
260 printf("Can't run config no module!!!\n");// Debug!!
261} 185}
262 186
263static void 187static void
264_module_about(void *data, void *data2) 188_module_about(void *data, void *data2)
265{ 189{
266 E_Config_Dialog *cfd; 190 Evas_Object *obj;
267 CFData *cfdata;
268 E_Module *m; 191 E_Module *m;
192 int i;
193 char *v;
269 194
270 cfd = data; 195 obj = data;
271 m = cfd->data; 196 i = e_widget_ilist_selected_get(obj);
272 cfdata = cfd->cfdata; 197 v = strdup(e_widget_ilist_selected_label_get(obj));
273 if (m->func.about) 198 m = e_module_find(v);
274 { 199 if (m)
275 m->func.about(m); 200 {
201 if (m->func.about)
202 {
203 m->func.about(m);
204 }
205 else
206 {
207 printf("Can't run about no module!!!\n");// Debug!!
208 }
276 } 209 }
277 else
278 printf("Can't run about no module!!!\n");// Debug!!
279} 210}
280 211
281 212
@@ -283,30 +214,7 @@ _module_about(void *data, void *data2)
283static void 214static void
284_fill_data(CFData *cfdata) 215_fill_data(CFData *cfdata)
285{ 216{
286 char buf[4096]; 217 return;
287 char fullpath[PATH_MAX];
288 Evas_List *l = NULL;
289
290 cfdata->umods = NULL;
291 cfdata->mods = NULL;
292 //e_module_list();
293
294 /* We could use e_module_list() but this method gives us alphabetical order */
295 for (l = e_path_dir_list_get(path_modules); l; l = l->next)
296 {
297 E_Path_Dir *epd;
298
299 epd = l->data;
300 _e_config_module_list(&(cfdata->mods), epd->dir, 1);
301 }
302
303 for (l = e_path_dir_list_get(path_modules); l; l = l->next)
304 {
305 E_Path_Dir *epd;
306
307 epd = l->data;
308 _e_config_module_list(&(cfdata->umods), epd->dir, 0);
309 }
310} 218}
311 219
312static void * 220static void *
@@ -319,7 +227,7 @@ _create_data(E_Config_Dialog *cfd)
319 CFData *cfdata; 227 CFData *cfdata;
320 228
321 cfdata = E_NEW(CFData, 1); 229 cfdata = E_NEW(CFData, 1);
322 _fill_data(cfdata); 230 cfdata->cfd = cfd;
323 return cfdata; 231 return cfdata;
324} 232}
325 233
@@ -348,59 +256,59 @@ static Evas_Object *
348_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata) 256_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
349{ 257{
350 /* generate the core widget layout for a basic dialog */ 258 /* generate the core widget layout for a basic dialog */
351 Evas_Object *o, *ob, *of, *sob; 259 Evas_Object *o, *ob, *of, *oc, *ilist;
352 E_Radio_Group *rg; 260 E_Radio_Group *rg;
353 Evas_List *l; 261 Evas_List *l;
354 E_Module *m; 262 E_Module *m;
355 263
356 _fill_data(cfdata);
357 cfd->hide_buttons = 1; 264 cfd->hide_buttons = 1;
265 cfd->cfdata = cfdata;
358 266
359 o = e_widget_list_add(evas, 0, 1); 267 o = e_widget_list_add(evas, 0, 1);
360 of = e_widget_framelist_add(evas, "Modules", 1); 268 of = e_widget_framelist_add(evas, "Modules", 1);
361 ob = e_widget_ilist_add(evas, 16, 16, NULL); 269 ilist = e_widget_ilist_add(evas, 16, 16, NULL);
362 for (l = cfdata->mods; l; l = l->next) 270 e_widget_on_change_hook_set(ilist, _ilist_cb_change, cfdata);
271
272 /* Loaded Modules */
273 for (l = e_config->modules; l; l = l->next)
363 { 274 {
364 E_Cfg_Mod_Data *cb_data; 275 E_Config_Module *em;
365 276
366 m = l->data; 277 em = l->data;
367 sob = e_icon_add(evas); 278 if (em->name) m = e_module_find(em->name);
368 if (m->icon_file) 279 if (m)
369 e_icon_file_set(sob, m->icon_file); 280 {
370 /*else if (mod->edje_icon_file) 281 oc = e_icon_add(evas);
371 * { 282 if (m->icon_file)
372 * if (mod->edje_icon_key) 283 e_icon_file_set(oc, m->icon_file);
373 */ 284 e_widget_ilist_append(ilist, oc, m->name, NULL, NULL, NULL);
374 cb_data = E_NEW(E_Cfg_Mod_Data, 1); 285 }
375 cb_data->loaded = 1;
376 cb_data->cfd = cfd;
377 cb_data->mod = m;
378 e_widget_ilist_append(ob, sob, m->name, _e_config_mod_cb_standard, cb_data, m->name);
379 } 286 }
380 e_widget_min_size_set(ob, 120, 120); 287
381 e_widget_ilist_go(ob); 288 e_widget_min_size_set(ilist, 120, 120);
382 e_widget_framelist_object_append(of, ob); 289 e_widget_ilist_go(ilist);
290 e_widget_framelist_object_append(of, ilist);
383 e_widget_list_object_append(o, of, 1, 1, 0.5); 291 e_widget_list_object_append(o, of, 1, 1, 0.5);
384 292
385 of = e_widget_frametable_add(evas, "Actions", 1); 293 of = e_widget_frametable_add(evas, "Actions", 1);
386 294
387 ob = e_widget_button_add(evas, "Enable", NULL, _module_enable, cfd, NULL); 295 ob = e_widget_button_add(evas, "Enable", NULL, _module_enable, ilist, cfdata);
388 cfdata->gui.enable = ob; 296 cfdata->gui.enable = ob;
389 e_widget_disabled_set(ob, 1); 297 e_widget_disabled_set(ob, 1);
390 e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 32, 32, 1, 1); 298 e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 32, 32, 1, 1);
391 299
392 ob = e_widget_button_add(evas, "Disable", NULL, _module_enable, cfd, NULL); 300 ob = e_widget_button_add(evas, "Disable", NULL, _module_disable, ilist, cfdata);
393 cfdata->gui.disable = ob; 301 cfdata->gui.disable = ob;
394 e_widget_disabled_set(ob, 1); 302 e_widget_disabled_set(ob, 1);
395 e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 32, 32, 1, 1); 303 e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 32, 32, 1, 1);
396 304
397 ob = e_widget_button_add(evas, "Configure", NULL, _module_configure, cfd, NULL); 305 ob = e_widget_button_add(evas, "Configure", NULL, _module_configure, ilist, NULL);
398 cfdata->gui.configure=ob; 306 cfdata->gui.configure = ob;
399 e_widget_disabled_set(ob, 1); 307 e_widget_disabled_set(ob, 1);
400 e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 32, 32, 1, 1); 308 e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 32, 32, 1, 1);
401 309
402 ob = e_widget_button_add(evas, "About", NULL, _module_about, cfd, NULL); 310 ob = e_widget_button_add(evas, "About", NULL, _module_about, ilist, NULL);
403 cfdata->gui.about=ob; 311 cfdata->gui.about = ob;
404 e_widget_disabled_set(ob, 1); 312 e_widget_disabled_set(ob, 1);
405 e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 32, 32, 1, 1); 313 e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 32, 32, 1, 1);
406 314
@@ -412,90 +320,210 @@ static Evas_Object *
412_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata) 320_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
413{ 321{
414 /* generate the core widget layout for an advanced dialog */ 322 /* generate the core widget layout for an advanced dialog */
415 Evas_Object *o, *ob, *of, *sob; 323 Evas_Object *o, *ob, *of, *oc, *ilist, *ilist2;
416 E_Radio_Group *rg; 324 E_Radio_Group *rg;
417 Evas_List *l; 325 Evas_List *l, *l2;
418 E_Module *m; 326 E_Module *m;
327 Ecore_List *modules;
328 char full_path[PATH_MAX];
329 int loaded;
330 char *icon;
331 char buf[PATH_MAX];
419 332
420 _fill_data(cfdata);
421 cfd->hide_buttons = 1; 333 cfd->hide_buttons = 1;
334 cfd->cfdata = cfdata;
422 335
423 o = e_widget_list_add(evas, 0, 1); 336 o = e_widget_list_add(evas, 0, 1);
424 337
425 of = e_widget_framelist_add(evas, "Loaded", 1); 338 of = e_widget_framelist_add(evas, "Loaded", 1);
426 ob = e_widget_ilist_add(evas, 16, 16, NULL); 339 ilist = e_widget_ilist_add(evas, 16, 16, NULL);
427 for (l = cfdata->mods; l; l = l->next) 340 e_widget_on_change_hook_set(ilist, _ilist_cb_change, cfdata);
341
342 /* Loaded Modules */
343 for (l = e_config->modules; l; l = l->next)
428 { 344 {
429 E_Cfg_Mod_Data *cb_data; 345 E_Config_Module *em;
430 346
431 m = l->data; 347 em = l->data;
432 sob = e_icon_add(evas); 348 if (em->name) m = e_module_find(em->name);
433 if (m->icon_file) 349 if (m)
434 e_icon_file_set(sob, m->icon_file); 350 {
435 cb_data = E_NEW(E_Cfg_Mod_Data, 1); 351 oc = e_icon_add(evas);
436 cb_data->cfd = cfd; 352 if (m->icon_file)
437 cb_data->loaded = 1; 353 e_icon_file_set(oc, m->icon_file);
438 cb_data->mod = m; 354 e_widget_ilist_append(ilist, oc, m->name, NULL, NULL, NULL);
439 e_widget_ilist_append(ob, sob, m->name, _e_config_mod_cb_standard, cb_data, m->name); 355 }
440 } 356 }
441 cfdata->gui.loaded = ob; 357
442 e_widget_ilist_go(ob); 358 e_widget_ilist_go(ilist);
443 e_widget_min_size_set(ob, 120, 120); 359 e_widget_min_size_set(ilist, 120, 120);
444 e_widget_framelist_object_append(of, ob); 360 e_widget_framelist_object_append(of, ilist);
445 e_widget_list_object_append(o, of, 1, 1, 0.5); 361 e_widget_list_object_append(o, of, 1, 1, 0.5);
446 362
363 ilist2 = e_widget_ilist_add(evas, 16, 16, NULL);
364 e_widget_on_change_hook_set(ilist2, _ilist2_cb_change, cfdata);
365
447 of = e_widget_frametable_add(evas, "Actions", 1); 366 of = e_widget_frametable_add(evas, "Actions", 1);
448 ob = e_widget_button_add(evas, "Load", NULL, _module_load, cfd, NULL); 367 ob = e_widget_button_add(evas, "Load", NULL, _module_load, ilist2, cfdata);
449 cfdata->gui.load = ob; 368 cfdata->gui.load = ob;
450 e_widget_disabled_set(ob, 1); 369 e_widget_disabled_set(ob, 1);
451 e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 32, 32, 1, 1); 370 e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 32, 32, 1, 1);
452 371
453 ob = e_widget_button_add(evas, "Enable", NULL, _module_enable, cfd, NULL); 372 ob = e_widget_button_add(evas, "Enable", NULL, _module_enable, ilist, cfdata);
454 cfdata->gui.enable = ob; 373 cfdata->gui.enable = ob;
455 e_widget_disabled_set(ob, 1); 374 e_widget_disabled_set(ob, 1);
456 e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 32, 32, 1, 1); 375 e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 32, 32, 1, 1);
457 376
458 ob = e_widget_button_add(evas, "Disable", NULL, _module_enable, cfd, NULL); 377 ob = e_widget_button_add(evas, "Disable", NULL, _module_disable, ilist, cfdata);
459 cfdata->gui.disable = ob; 378 cfdata->gui.disable = ob;
460 e_widget_disabled_set(ob, 1); 379 e_widget_disabled_set(ob, 1);
461 e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 32, 32, 1, 1); 380 e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 32, 32, 1, 1);
462 381
463 ob = e_widget_button_add(evas, "Unload", NULL, _module_unload, cfd, NULL); 382 ob = e_widget_button_add(evas, "Unload", NULL, _module_unload, ilist, cfdata);
464 cfdata->gui.unload = ob; 383 cfdata->gui.unload = ob;
465 e_widget_disabled_set(ob, 1); 384 e_widget_disabled_set(ob, 1);
466 e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 32, 32, 1, 1); 385 e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 32, 32, 1, 1);
467 386
468 ob = e_widget_button_add(evas, "Configure", NULL, _module_configure, cfd, NULL); 387 ob = e_widget_button_add(evas, "Configure", NULL, _module_configure, ilist, NULL);
469 cfdata->gui.configure = ob; 388 cfdata->gui.configure = ob;
470 e_widget_disabled_set(ob, 1); 389 e_widget_disabled_set(ob, 1);
471 e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 32, 32, 1, 1); 390 e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 32, 32, 1, 1);
472 e_widget_list_object_append(o, of, 1, 1, 0.5); 391 e_widget_list_object_append(o, of, 1, 1, 0.5);
473 392
474 of = e_widget_framelist_add(evas, "Unloaded", 1); 393 of = e_widget_framelist_add(evas, "Unloaded", 1);
475 ob = e_widget_ilist_add(evas, 16, 16, NULL); 394
476 for (l = cfdata->umods; l; l = l->next) 395 /* Get Modules; For each module, if it's not loaded, list it */
396 l = NULL;
397 for (l = e_path_dir_list_get(path_modules); l; l = l->next)
477 { 398 {
478 char *mod; 399 E_Path_Dir *epd;
479 char *icon;
480 char buf[PATH_MAX];
481 E_Cfg_Mod_Data *cb_data;
482 400
483 mod = l->data; 401 epd = l->data;
484 sob = e_icon_add(evas); 402 if ((ecore_file_exists(epd->dir)) && (ecore_file_is_dir(epd->dir)))
485 snprintf(buf, sizeof(buf), "%s/module_icon.png", mod); 403 {
486 icon = e_path_find(path_modules, buf); 404 modules = ecore_file_ls(epd->dir);
487 e_icon_file_set(sob,icon); 405 if (modules)
488 cb_data = E_NEW(CFData,1); 406 {
489 cb_data->cfd = cfd; 407 char *mod;
490 cb_data->loaded = 0; 408 while ((mod = ecore_list_next(modules)))
491 cb_data->mod_name = strdup(mod); 409 {
492 e_widget_ilist_append(ob, sob, mod, _e_config_mod_cb_standard, cb_data, mod); 410 snprintf(full_path, sizeof(full_path), "%s/%s", epd->dir, mod);
411 snprintf(buf, sizeof(buf), "%s/module_icon.png", mod);
412 if (ecore_file_is_dir(full_path))
413 {
414 E_Module *m;
415 m = e_module_find(mod);
416 if (m)
417 {
418 loaded = 0;
419 for (l = e_config->modules; l; l = l->next)
420 {
421 E_Config_Module *em;
422
423 em = l->data;
424 if (!strcmp(m->name, em->name))
425 {
426 loaded = 1;
427 break;
428 }
429 }
430 }
431 if ((!m) || (!loaded))
432 {
433 oc = e_icon_add(evas);
434 icon = e_path_find(path_modules, buf);
435 e_icon_file_set(oc, icon);
436 e_widget_ilist_append(ilist2, oc, mod, NULL, NULL, NULL);
437 }
438 }
439 }
440 }
441 }
493 } 442 }
494 cfdata->gui.unloaded = ob; 443
495 e_widget_ilist_go(ob); 444 ecore_list_destroy(modules);
496 e_widget_min_size_set(ob, 120, 120); 445
497 e_widget_framelist_object_append(of, ob); 446 e_widget_ilist_go(ilist2);
447 e_widget_min_size_set(ilist2, 120, 120);
448 e_widget_framelist_object_append(of, ilist2);
498 e_widget_list_object_append(o, of, 1, 1, 0.5); 449 e_widget_list_object_append(o, of, 1, 1, 0.5);
499 return o; 450 return o;
500} 451}
501 452
453static void
454_ilist_cb_change(void *data, Evas_Object *obj)
455{
456 E_Module *m;
457 E_Config_Dialog *cfd;
458 CFData *cfdata;
459 int i;
460 char *v;
461
462 cfdata = data;
463 cfd = cfdata->cfd;
464 i = e_widget_ilist_selected_get(obj);
465 v = strdup(e_widget_ilist_selected_label_get(obj));
466 m = e_module_find(v);
467 if (m)
468 {
469 if (m->enabled)
470 {
471 e_widget_disabled_set(cfdata->gui.enable, 1);
472 e_widget_disabled_set(cfdata->gui.disable, 0);
473 if (m->func.config)
474 e_widget_disabled_set(cfdata->gui.configure, 0);
475 else
476 e_widget_disabled_set(cfdata->gui.configure, 1);
477 }
478 else
479 {
480 e_widget_disabled_set(cfdata->gui.configure, 1);
481 e_widget_disabled_set(cfdata->gui.enable, 0);
482 e_widget_disabled_set(cfdata->gui.disable, 1);
483 }
484
485 if (m->func.about)
486 e_widget_disabled_set(cfdata->gui.about, 0);
487 else
488 e_widget_disabled_set(cfdata->gui.about, 1);
489 }
490
491 if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED)
492 {
493 if (!m)
494 {
495 e_widget_disabled_set(cfdata->gui.load, 0);
496 e_widget_disabled_set(cfdata->gui.unload, 1);
497 }
498 else
499 {
500 e_widget_disabled_set(cfdata->gui.load, 1);
501 e_widget_disabled_set(cfdata->gui.unload, 0);
502 }
503 }
504}
505
506static void
507_ilist2_cb_change(void *data, Evas_Object *obj)
508{
509 E_Module *m;
510 E_Config_Dialog *cfd;
511 CFData *cfdata;
512 int i;
513 char *v;
514
515 cfdata = data;
516 cfd = cfdata->cfd;
517 i = e_widget_ilist_selected_get(obj);
518 v = strdup(e_widget_ilist_selected_label_get(obj));
519
520 m = e_module_find(v);
521 if (!m)
522 {
523 e_widget_disabled_set(cfdata->gui.configure, 1);
524 e_widget_disabled_set(cfdata->gui.enable, 1);
525 e_widget_disabled_set(cfdata->gui.disable, 1);
526 e_widget_disabled_set(cfdata->gui.unload, 1);
527 e_widget_disabled_set(cfdata->gui.load, 0);
528 }
529}