2007-08-12 03:16:26 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2007-09-16 11:32:32 -07:00
|
|
|
static void _e_wizard_next_eval(void);
|
2007-08-12 07:34:53 -07:00
|
|
|
static E_Popup *_e_wizard_main_new(E_Zone *zone);
|
|
|
|
static E_Popup *_e_wizard_extra_new(E_Zone *zone);
|
2007-08-18 08:55:48 -07:00
|
|
|
static void _e_wizard_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
|
|
|
static void _e_wizard_cb_next(void *data, Evas_Object *obj, const char *emission, const char *source);
|
2007-08-12 07:34:53 -07:00
|
|
|
|
|
|
|
static E_Popup *pop = NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *pops = NULL;
|
2007-08-18 08:55:48 -07:00
|
|
|
static Evas_Object *o_bg = NULL;
|
|
|
|
static Evas_Object *o_content = NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *pages = NULL;
|
2007-09-13 06:56:36 -07:00
|
|
|
static E_Wizard_Page *curpage = NULL;
|
2007-09-16 11:32:32 -07:00
|
|
|
static int next_ok = 1;
|
|
|
|
static int next_can = 0;
|
|
|
|
static int next_prev = 0;
|
2007-08-12 07:34:53 -07:00
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI int
|
2007-08-12 03:16:26 -07:00
|
|
|
e_wizard_init(void)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
for (l = e_manager_list(); l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Manager *man;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l2;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
man = l->data;
|
|
|
|
for (l2 = man->containers; l2; l2 = l2->next)
|
|
|
|
{
|
|
|
|
E_Container *con;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l3;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
con = l2->data;
|
|
|
|
for (l3 = con->zones; l3; l3 = l3->next)
|
|
|
|
{
|
|
|
|
E_Zone *zone;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
zone = l3->data;
|
|
|
|
if (!pop)
|
|
|
|
pop = _e_wizard_main_new(zone);
|
|
|
|
else
|
2008-10-22 04:49:33 -07:00
|
|
|
pops = eina_list_append(pops, _e_wizard_extra_new(zone));
|
2007-08-12 07:34:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-12 03:16:26 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI int
|
2007-08-12 03:16:26 -07:00
|
|
|
e_wizard_shutdown(void)
|
|
|
|
{
|
2007-08-12 07:34:53 -07:00
|
|
|
if (pop)
|
|
|
|
{
|
|
|
|
e_object_del(E_OBJECT(pop));
|
|
|
|
pop = NULL;
|
|
|
|
}
|
|
|
|
while (pops)
|
|
|
|
{
|
|
|
|
e_object_del(E_OBJECT(pops->data));
|
2008-10-22 04:49:33 -07:00
|
|
|
pops = eina_list_remove_list(pops, pops);
|
2007-08-12 07:34:53 -07:00
|
|
|
}
|
2007-09-14 09:57:01 -07:00
|
|
|
while (pages)
|
|
|
|
{
|
|
|
|
e_wizard_page_del(pages->data);
|
|
|
|
}
|
2007-08-12 03:16:26 -07:00
|
|
|
return 1;
|
|
|
|
}
|
2007-08-12 07:34:53 -07:00
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-13 06:56:36 -07:00
|
|
|
e_wizard_go(void)
|
|
|
|
{
|
|
|
|
if (!curpage)
|
|
|
|
{
|
2007-09-16 11:32:32 -07:00
|
|
|
if (pages)
|
|
|
|
{
|
|
|
|
curpage = pages->data;
|
|
|
|
if (pages->next) next_can = 1;
|
|
|
|
}
|
2007-09-13 06:56:36 -07:00
|
|
|
}
|
|
|
|
if (curpage)
|
|
|
|
{
|
2007-09-14 06:58:18 -07:00
|
|
|
if ((!curpage->data) && (curpage->init)) curpage->init(curpage);
|
2007-09-16 11:32:32 -07:00
|
|
|
_e_wizard_next_eval();
|
2007-09-14 06:58:18 -07:00
|
|
|
if ((curpage->show) && (!curpage->show(curpage)))
|
|
|
|
{
|
|
|
|
e_wizard_next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-14 06:58:18 -07:00
|
|
|
e_wizard_apply(void)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-14 06:58:18 -07:00
|
|
|
for (l = pages; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Wizard_Page *pg;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-14 06:58:18 -07:00
|
|
|
pg = l->data;
|
|
|
|
if (pg->apply) pg->apply(pg);
|
2007-09-13 06:56:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-13 06:56:36 -07:00
|
|
|
e_wizard_next(void)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-13 06:56:36 -07:00
|
|
|
for (l = pages; l; l = l->next)
|
|
|
|
{
|
|
|
|
if (l->data == curpage)
|
|
|
|
{
|
|
|
|
if (l->next)
|
|
|
|
{
|
|
|
|
if (curpage)
|
|
|
|
{
|
2007-09-14 06:58:18 -07:00
|
|
|
if (curpage->hide)
|
|
|
|
curpage->hide(curpage);
|
2007-09-13 06:56:36 -07:00
|
|
|
}
|
|
|
|
curpage = l->next->data;
|
|
|
|
if (!curpage->data)
|
|
|
|
{
|
2007-09-14 06:58:18 -07:00
|
|
|
if (curpage->init)
|
|
|
|
curpage->init(curpage);
|
2007-09-13 06:56:36 -07:00
|
|
|
}
|
2007-09-16 11:32:32 -07:00
|
|
|
next_can = 1;
|
|
|
|
_e_wizard_next_eval();
|
2007-09-14 06:58:18 -07:00
|
|
|
if ((curpage->show) && (curpage->show(curpage)))
|
2007-09-13 06:56:36 -07:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FINISH */
|
2007-09-14 06:58:18 -07:00
|
|
|
e_wizard_apply();
|
|
|
|
e_wizard_shutdown();
|
|
|
|
return;
|
2007-09-13 06:56:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-13 06:56:36 -07:00
|
|
|
e_wizard_page_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
if (o_content) evas_object_del(o_content);
|
|
|
|
o_content = obj;
|
|
|
|
if (obj)
|
|
|
|
{
|
2010-08-19 09:52:09 -07:00
|
|
|
Evas_Coord minw, minh;
|
|
|
|
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(obj, &minw, &minh);
|
2007-09-13 06:56:36 -07:00
|
|
|
edje_extern_object_min_size_set(obj, minw, minh);
|
|
|
|
edje_object_part_swallow(o_bg, "e.swallow.content", obj);
|
|
|
|
evas_object_show(obj);
|
|
|
|
e_widget_focus_set(obj, 1);
|
|
|
|
edje_object_signal_emit(o_bg, "e,action,page,new", "e");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI E_Wizard_Page *
|
2007-09-14 09:57:01 -07:00
|
|
|
e_wizard_page_add(void *handle,
|
|
|
|
int (*init) (E_Wizard_Page *pg),
|
2007-09-13 06:56:36 -07:00
|
|
|
int (*shutdown) (E_Wizard_Page *pg),
|
|
|
|
int (*show) (E_Wizard_Page *pg),
|
|
|
|
int (*hide) (E_Wizard_Page *pg),
|
|
|
|
int (*apply) (E_Wizard_Page *pg)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
E_Wizard_Page *pg;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-13 06:56:36 -07:00
|
|
|
pg = E_NEW(E_Wizard_Page, 1);
|
|
|
|
if (!pg) return NULL;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
pg->handle = handle;
|
2007-09-13 06:56:36 -07:00
|
|
|
pg->evas = pop->evas;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-13 06:56:36 -07:00
|
|
|
pg->init = init;
|
|
|
|
pg->shutdown = shutdown;
|
|
|
|
pg->show = show;
|
|
|
|
pg->hide = hide;
|
|
|
|
pg->apply = apply;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
pages = eina_list_append(pages, pg);
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-13 06:56:36 -07:00
|
|
|
return pg;
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-13 06:56:36 -07:00
|
|
|
e_wizard_page_del(E_Wizard_Page *pg)
|
|
|
|
{
|
2011-08-15 02:21:12 -07:00
|
|
|
// rare thing.. if we do e_wizard_next() from a page and we end up finishing
|
|
|
|
// ther page seq.. we cant REALLY dlclose... not a problem as wizard runs
|
|
|
|
// once only then e restarts itself with final wizard page
|
|
|
|
// if (pg->handle) dlclose(pg->handle);
|
2008-10-22 04:49:33 -07:00
|
|
|
pages = eina_list_remove(pages, pg);
|
2007-09-13 06:56:36 -07:00
|
|
|
free(pg);
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-16 11:32:32 -07:00
|
|
|
e_wizard_button_next_enable_set(int enable)
|
|
|
|
{
|
|
|
|
next_ok = enable;
|
|
|
|
_e_wizard_next_eval();
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2007-09-16 22:10:05 -07:00
|
|
|
e_wizard_title_set(const char *title)
|
|
|
|
{
|
|
|
|
edje_object_part_text_set(o_bg, "e.text.title", title);
|
|
|
|
}
|
|
|
|
|
2010-02-27 02:06:22 -08:00
|
|
|
EAPI void
|
2008-10-24 23:54:38 -07:00
|
|
|
e_wizard_labels_update(void)
|
2007-09-16 11:32:32 -07:00
|
|
|
{
|
2008-10-24 23:54:38 -07:00
|
|
|
edje_object_part_text_set(o_bg, "e.text.label", _("Next"));
|
2007-09-16 11:32:32 -07:00
|
|
|
}
|
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
EAPI const char *
|
|
|
|
e_wizard_dir_get(void)
|
|
|
|
{
|
|
|
|
return e_module_dir_get(wiz_module);
|
|
|
|
}
|
|
|
|
|
2007-09-16 11:32:32 -07:00
|
|
|
static void
|
|
|
|
_e_wizard_next_eval(void)
|
|
|
|
{
|
|
|
|
int ok;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-09-16 11:32:32 -07:00
|
|
|
ok = next_can;
|
|
|
|
if (!next_ok) ok = 0;
|
|
|
|
if (next_prev != ok)
|
|
|
|
{
|
|
|
|
if (ok) edje_object_signal_emit(o_bg, "e,state,next,enable", "e");
|
|
|
|
else edje_object_signal_emit(o_bg, "e,state,next,disable", "e");
|
|
|
|
next_prev = ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
static E_Popup *
|
|
|
|
_e_wizard_main_new(E_Zone *zone)
|
|
|
|
{
|
|
|
|
E_Popup *pop;
|
2010-01-15 11:36:00 -08:00
|
|
|
Evas_Object *o;
|
2007-08-18 08:55:48 -07:00
|
|
|
Evas_Modifier_Mask mask;
|
2009-04-21 02:55:54 -07:00
|
|
|
Eina_Bool kg;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2009-03-13 00:54:04 -07:00
|
|
|
pop = e_popup_new(zone, 0, 0, zone->w, zone->h);
|
2007-08-12 07:34:53 -07:00
|
|
|
e_popup_layer_set(pop, 255);
|
|
|
|
o = edje_object_add(pop->evas);
|
2008-10-24 23:54:38 -07:00
|
|
|
|
|
|
|
e_theme_edje_object_set(o, "base/theme/wizard", "e/wizard/main");
|
2007-08-12 07:34:53 -07:00
|
|
|
evas_object_move(o, 0, 0);
|
|
|
|
evas_object_resize(o, zone->w, zone->h);
|
|
|
|
evas_object_show(o);
|
2007-09-13 06:56:36 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,next", "",
|
2007-08-18 08:55:48 -07:00
|
|
|
_e_wizard_cb_next, pop);
|
2007-08-12 07:34:53 -07:00
|
|
|
o_bg = o;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-18 08:55:48 -07:00
|
|
|
o = evas_object_rectangle_add(pop->evas);
|
|
|
|
mask = 0;
|
2009-04-21 02:55:54 -07:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
2009-04-21 13:45:38 -07:00
|
|
|
if (!kg)
|
2010-08-19 09:52:09 -07:00
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2007-08-18 08:55:48 -07:00
|
|
|
mask = evas_key_modifier_mask_get(pop->evas, "Shift");
|
2009-04-21 02:55:54 -07:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
2009-04-21 13:45:38 -07:00
|
|
|
if (!kg)
|
2010-08-19 09:52:09 -07:00
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2007-08-18 08:55:48 -07:00
|
|
|
mask = 0;
|
2009-04-21 02:55:54 -07:00
|
|
|
kg = evas_object_key_grab(o, "Return", mask, ~mask, 0);
|
2009-04-21 13:45:38 -07:00
|
|
|
if (!kg)
|
2010-08-19 09:52:09 -07:00
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Return\" key events to object %p.\n", o);
|
2007-08-18 08:55:48 -07:00
|
|
|
mask = 0;
|
2009-04-21 02:55:54 -07:00
|
|
|
kg = evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0);
|
2009-04-21 13:45:38 -07:00
|
|
|
if (!kg)
|
2010-08-19 09:52:09 -07:00
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"KP_Enter\" key events to object %p.\n", o);
|
2007-08-18 08:55:48 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
|
|
|
|
_e_wizard_cb_key_down, pop);
|
|
|
|
|
|
|
|
/* set up next/prev buttons */
|
2008-10-24 23:54:38 -07:00
|
|
|
edje_object_part_text_set(o_bg, "e.text.title", _("Welcome to Enlightenment"));
|
2007-08-18 08:55:48 -07:00
|
|
|
edje_object_signal_emit(o_bg, "e,state,next,disable", "e");
|
2008-10-24 23:54:38 -07:00
|
|
|
e_wizard_labels_update();
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-12 07:34:53 -07:00
|
|
|
e_popup_edje_bg_object_set(pop, o_bg);
|
|
|
|
e_popup_show(pop);
|
2009-04-11 01:42:24 -07:00
|
|
|
if (!e_grabinput_get(ecore_evas_software_x11_window_get(pop->ecore_evas),
|
|
|
|
1, ecore_evas_software_x11_window_get(pop->ecore_evas)))
|
2007-08-12 07:34:53 -07:00
|
|
|
{
|
|
|
|
e_object_del(E_OBJECT(pop));
|
|
|
|
pop = NULL;
|
|
|
|
}
|
|
|
|
return pop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Popup *
|
|
|
|
_e_wizard_extra_new(E_Zone *zone)
|
|
|
|
{
|
|
|
|
E_Popup *pop;
|
|
|
|
Evas_Object *o;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2009-03-13 00:54:04 -07:00
|
|
|
pop = e_popup_new(zone, 0, 0, zone->w, zone->h);
|
2007-08-12 07:34:53 -07:00
|
|
|
e_popup_layer_set(pop, 255);
|
|
|
|
o = edje_object_add(pop->evas);
|
2008-10-24 23:54:38 -07:00
|
|
|
e_theme_edje_object_set(o, "base/theme/wizard", "e/wizard/extra");
|
2007-08-12 07:34:53 -07:00
|
|
|
evas_object_move(o, 0, 0);
|
|
|
|
evas_object_resize(o, zone->w, zone->h);
|
|
|
|
evas_object_show(o);
|
|
|
|
e_popup_edje_bg_object_set(pop, o);
|
|
|
|
e_popup_show(pop);
|
|
|
|
return pop;
|
|
|
|
}
|
2007-08-18 08:55:48 -07:00
|
|
|
|
|
|
|
static void
|
2010-08-19 09:52:09 -07:00
|
|
|
_e_wizard_cb_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2007-08-18 08:55:48 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-18 08:55:48 -07:00
|
|
|
ev = event;
|
|
|
|
if (!o_content) return;
|
|
|
|
if (!strcmp(ev->keyname, "Tab"))
|
|
|
|
{
|
2007-09-13 06:56:36 -07:00
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
2007-08-18 08:55:48 -07:00
|
|
|
e_widget_focus_jump(o_content, 0);
|
|
|
|
else
|
|
|
|
e_widget_focus_jump(o_content, 1);
|
|
|
|
}
|
|
|
|
else if (((!strcmp(ev->keyname, "Return")) ||
|
|
|
|
(!strcmp(ev->keyname, "KP_Enter")) ||
|
|
|
|
(!strcmp(ev->keyname, "space"))))
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
2010-08-19 09:52:09 -07:00
|
|
|
|
2007-08-18 08:55:48 -07:00
|
|
|
o = e_widget_focused_object_get(o_content);
|
|
|
|
if (o) e_widget_activate(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 09:52:09 -07:00
|
|
|
_e_wizard_cb_next(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2007-08-18 08:55:48 -07:00
|
|
|
{
|
2007-09-13 06:56:36 -07:00
|
|
|
e_wizard_next();
|
2007-08-18 08:55:48 -07:00
|
|
|
}
|