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