a52098de396045db8359502b07163b9fc519d6cb
[framework/uifw/e17.git] / src / modules / wizard / e_mod_main.c
1 #include "e.h"
2 #include "e_mod_main.h"
3
4 /* actual module specifics */
5 static E_Module *conf_module = NULL;
6
7 /*
8  * These are the currently planned wizard pages:
9  * 
10  * o == interactive
11  * . == automatic (no gui - none implemented currently)
12  * 
13  * * = done
14  * - = code here, but disabled in build
15  * 
16  * --- THE LIST
17  * o *ask for language (default selection is current locale).
18  * o *ask for initial profile
19  * o *find XDG app menus/repositories and list them let user choose which
20  *    one(s) are to be used.
21  * o -ask for ibar initial app set
22  * o -ask if user wants desktop icons or not (enable fwin module but seed it
23  *    with default config icons on desktop and favorites).
24  * o -ask click to focus or sloppy
25  * . *take some of current config (language, fileman, profile) and load
26  *    load profile, apply language to it and save, restart e.
27  * 
28  * why are some disabled? profiels take care of this and do a better job
29  * at collecting all the things together. for example illume makes no sense
30  * with pointer focus and ibar icons/desktop makes no sense.
31  */
32
33 /* module setup */
34 EAPI E_Module_Api e_modapi =
35 {
36    E_MODULE_API_VERSION,
37      "Wizard"
38 };
39
40 static int 
41 _cb_sort_files(char *f1, char *f2)
42 {
43    return strcmp(f1, f2);
44 }
45
46 EAPI void *
47 e_modapi_init(E_Module *m)
48 {
49    Eina_List *files;
50    char buf[PATH_MAX];
51    char *file;
52    
53    conf_module = m;
54    e_wizard_init();
55    
56    snprintf(buf, sizeof(buf), "%s/%s", e_module_dir_get(m), MODULE_ARCH);
57    files = ecore_file_ls(buf);
58    files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
59    EINA_LIST_FREE(files, file)
60           {
61              if (!strncmp(file, "page_", 5))
62                {
63                   void *handle;
64                   
65                   snprintf(buf, sizeof(buf), "%s/%s/%s",
66                            e_module_dir_get(m), MODULE_ARCH, file);
67                   handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
68                   if (handle)
69                     {
70                        e_wizard_page_add(handle,
71                                          dlsym(handle, "wizard_page_init"),
72                                          dlsym(handle, "wizard_page_shutdown"),
73                                          dlsym(handle, "wizard_page_show"),
74                                          dlsym(handle, "wizard_page_hide"),
75                                          dlsym(handle, "wizard_page_apply"));
76                     }
77                   else
78                     printf("%s\n", dlerror());
79                }
80         free(file);
81      }
82    e_wizard_go();
83    
84    return m;
85 }
86
87 EAPI int
88 e_modapi_shutdown(E_Module *m __UNUSED__)
89 {
90    e_wizard_shutdown();
91    conf_module = NULL;
92 // FIXME: wrong place   
93 //   e_module_disable(m); /* disable - on restart this won't be loaded now */
94 //   e_sys_action_do(E_SYS_RESTART, NULL); /* restart e - cleanly try settings */
95    return 1;
96 }
97
98 EAPI int
99 e_modapi_save(E_Module *m __UNUSED__)
100 {
101    return 1;
102 }