moving wizard pages to their own files - modules loaded. in alphabetical

order only if they start with "page_". this way 3rd parties can add new
wizard pages post e install (or remove them) without a recompile needed.


SVN revision: 31712
This commit is contained in:
Carsten Haitzler 2007-09-14 16:57:01 +00:00
parent 4e1db54233
commit 67766a472a
7 changed files with 194 additions and 86 deletions

View File

@ -17,15 +17,34 @@ INCLUDES = -I. \
-I$(top_srcdir)/src/modules \
@e_cflags@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
pkg_LTLIBRARIES = module.la \
page_000.la \
page_100.la \
page_200.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
e_wizard.c \
e_wizard.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
page_000_la_SOURCES = page_000.c
page_000_la_LIBADD = @e_libs@ @dlopen_libs@
page_000_la_LDFLAGS = -module -avoid-version
page_000_la_DEPENDENCIES = $(top_builddir)/config.h
page_100_la_SOURCES = page_100.c
page_100_la_LIBADD = @e_libs@ @dlopen_libs@
page_100_la_LDFLAGS = -module -avoid-version
page_100_la_DEPENDENCIES = $(top_builddir)/config.h
page_200_la_SOURCES = page_200.c
page_200_la_LIBADD = @e_libs@ @dlopen_libs@
page_200_la_LDFLAGS = -module -avoid-version
page_200_la_DEPENDENCIES = $(top_builddir)/config.h
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

View File

@ -29,92 +29,45 @@ EAPI E_Module_Api e_modapi =
};
static int t0_init (E_Wizard_Page *pg){
return 1;
}
static int t0_shutdown (E_Wizard_Page *pg){
return 1;
}
static int t0_show (E_Wizard_Page *pg){
printf("t0\n");
return 0; /* 1 == show ui, and wait for user, 0 == just continue */
}
static int t0_hide (E_Wizard_Page *pg){
return 1;
}
static int t0_apply (E_Wizard_Page *pg){
printf("a0\n");
return 1;
}
static int t1_init (E_Wizard_Page *pg){
return 1;
}
static int t1_shutdown (E_Wizard_Page *pg){
return 1;
}
static int t1_show (E_Wizard_Page *pg){
Evas_Object *ob, *o;
printf("t1\n");
ob = e_widget_list_add(pg->evas, 1, 0);
o = e_widget_button_add(pg->evas,
"Hello World", NULL,
NULL, NULL, NULL);
e_widget_list_object_append(ob, o, 0, 0, 0.5);
evas_object_show(o);
e_wizard_page_show(ob);
pg->data = ob;
return 1; /* 1 == show ui, and wait for user, 0 == just continue */
}
static int t1_hide (E_Wizard_Page *pg){
evas_object_del(pg->data);
return 1;
}
static int t1_apply (E_Wizard_Page *pg){
printf("a1\n");
return 1;
}
static int t2_init (E_Wizard_Page *pg){
return 1;
}
static int t2_shutdown (E_Wizard_Page *pg){
return 1;
}
static int t2_show (E_Wizard_Page *pg){
Evas_Object *ob, *o;
printf("t2\n");
ob = e_widget_list_add(pg->evas, 1, 0);
o = e_widget_button_add(pg->evas,
"Hello to Another World", NULL,
NULL, NULL, NULL);
e_widget_list_object_append(ob, o, 0, 0, 0.5);
evas_object_show(o);
e_wizard_page_show(ob);
pg->data = ob;
return 1;
}
static int t2_hide (E_Wizard_Page *pg){
evas_object_del(pg->data);
return 1;
}
static int t2_apply (E_Wizard_Page *pg){
printf("a2\n");
return 1;
}
EAPI void *
e_modapi_init(E_Module *m)
{
Ecore_List *files;
char buf[PATH_MAX];
conf_module = m;
e_wizard_init();
e_wizard_page_add(t0_init, t0_shutdown, t0_show, t0_hide, t0_apply);
e_wizard_page_add(t1_init, t1_shutdown, t1_show, t1_hide, t1_apply);
e_wizard_page_add(t2_init, t2_shutdown, t2_show, t2_hide, t2_apply);
snprintf(buf, sizeof(buf), "%s/%s", e_module_dir_get(m), MODULE_ARCH);
files = ecore_file_ls(buf);
if (files)
{
char *file;
ecore_list_first_goto(files);
while ((file = ecore_list_current(files)))
{
if (!strncmp(file, "page_", 5))
{
void *handle;
snprintf(buf, sizeof(buf), "%s/%s/%s",
e_module_dir_get(m), MODULE_ARCH, file);
handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
if (handle)
{
e_wizard_page_add(handle,
dlsym(handle, "wizard_page_init"),
dlsym(handle, "wizard_page_shutdown"),
dlsym(handle, "wizard_page_show"),
dlsym(handle, "wizard_page_hide"),
dlsym(handle, "wizard_page_apply"));
}
}
ecore_list_next(files);
}
ecore_list_destroy(files);
}
e_wizard_go();
@ -126,6 +79,9 @@ e_modapi_shutdown(E_Module *m)
{
e_wizard_shutdown();
conf_module = NULL;
// FIXME: wrong place
// e_module_disable(m); /* disable - on restart this won't be loaded now */
// e_sys_action_do(E_SYS_RESTART, NULL); /* restart e - cleanly try settings */
return 1;
}

View File

@ -62,7 +62,10 @@ e_wizard_shutdown(void)
e_object_del(E_OBJECT(pops->data));
pops = evas_list_remove_list(pops, pops);
}
/* FIXME: remove wizard module */
while (pages)
{
e_wizard_page_del(pages->data);
}
return 1;
}
@ -190,7 +193,8 @@ e_wizard_page_show(Evas_Object *obj)
/* FIXME: decide how pages are defined - how about an array of page structs? */
EAPI E_Wizard_Page *
e_wizard_page_add(int (*init) (E_Wizard_Page *pg),
e_wizard_page_add(void *handle,
int (*init) (E_Wizard_Page *pg),
int (*shutdown) (E_Wizard_Page *pg),
int (*show) (E_Wizard_Page *pg),
int (*hide) (E_Wizard_Page *pg),
@ -202,19 +206,24 @@ e_wizard_page_add(int (*init) (E_Wizard_Page *pg),
pg = E_NEW(E_Wizard_Page, 1);
if (!pg) return NULL;
pages = evas_list_append(pages, pg);
pg->handle = handle;
pg->evas = pop->evas;
pg->init = init;
pg->shutdown = shutdown;
pg->show = show;
pg->hide = hide;
pg->apply = apply;
pages = evas_list_append(pages, pg);
return pg;
}
EAPI void
e_wizard_page_del(E_Wizard_Page *pg)
{
if (pg->handle) dlclose(pg->handle);
pages = evas_list_remove(pages, pg);
free(pg);
}

View File

@ -11,6 +11,7 @@ typedef struct _E_Wizard_Page E_Wizard_Page;
struct _E_Wizard_Page
{
void *handle;
Evas *evas;
int (*init) (E_Wizard_Page *pg);
int (*shutdown) (E_Wizard_Page *pg);
@ -23,11 +24,13 @@ struct _E_Wizard_Page
EAPI int e_wizard_init(void);
EAPI int e_wizard_shutdown(void);
EAPI void e_wizard_go(void);
EAPI void e_wizard_apply(void);
EAPI void e_wizard_next(void);
EAPI void e_wizard_back(void);
EAPI void e_wizard_page_show(Evas_Object *obj);
EAPI E_Wizard_Page *
e_wizard_page_add(int (*init) (E_Wizard_Page *pg),
e_wizard_page_add(void *handle,
int (*init) (E_Wizard_Page *pg),
int (*shutdown) (E_Wizard_Page *pg),
int (*show) (E_Wizard_Page *pg),
int (*hide) (E_Wizard_Page *pg),

View File

@ -0,0 +1,33 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg)
{
printf("t0\n");
return 0; /* 1 == show ui, and wait for user, 0 == just continue */
}
EAPI int
wizard_page_hide(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_apply(E_Wizard_Page *pg)
{
printf("a0\n");
return 1;
}

View File

@ -0,0 +1,44 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg)
{
Evas_Object *ob, *o;
printf("t1\n");
ob = e_widget_list_add(pg->evas, 1, 0);
o = e_widget_button_add(pg->evas,
"Hello World", NULL,
NULL, NULL, NULL);
e_widget_list_object_append(ob, o, 0, 0, 0.5);
evas_object_show(o);
e_wizard_page_show(ob);
pg->data = ob;
return 1; /* 1 == show ui, and wait for user, 0 == just continue */
}
EAPI int
wizard_page_hide(E_Wizard_Page *pg)
{
evas_object_del(pg->data);
return 1;
}
EAPI int
wizard_page_apply(E_Wizard_Page *pg)
{
printf("a1\n");
return 1;
}

View File

@ -0,0 +1,44 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg)
{
return 1;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg)
{
Evas_Object *ob, *o;
printf("t2\n");
ob = e_widget_list_add(pg->evas, 1, 0);
o = e_widget_button_add(pg->evas,
"Hello Another World", NULL,
NULL, NULL, NULL);
e_widget_list_object_append(ob, o, 0, 0, 0.5);
evas_object_show(o);
e_wizard_page_show(ob);
pg->data = ob;
return 1; /* 1 == show ui, and wait for user, 0 == just continue */
}
EAPI int
wizard_page_hide(E_Wizard_Page *pg)
{
evas_object_del(pg->data);
return 1;
}
EAPI int
wizard_page_apply(E_Wizard_Page *pg)
{
printf("a2\n");
return 1;
}