e/wizard: improve waiting for cache build

SVN revision: 79708
This commit is contained in:
Sebastian Dransfeld 2012-11-26 12:40:31 +00:00
parent 8e103026d9
commit 8ddf5f934b
23 changed files with 144 additions and 97 deletions

View File

@ -1,12 +1,16 @@
#include "e.h"
#include "e_mod_main.h"
static void _e_wizard_next_eval(void);
static int _e_wizard_next_eval(void);
static E_Popup *_e_wizard_main_new(E_Zone *zone);
static E_Popup *_e_wizard_extra_new(E_Zone *zone);
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);
static Eina_Bool _e_wizard_cb_next_page(void *data);
static Eina_Bool _e_wizard_cb_desktops_update(void *data, int ev_type, void *ev);
static Eina_Bool _e_wizard_cb_icons_update(void *data, int ev_type, void *ev);
static E_Popup *pop = NULL;
static Eina_List *pops = NULL;
static Evas_Object *o_bg = NULL;
@ -14,8 +18,17 @@ static Evas_Object *o_content = NULL;
static Eina_List *pages = NULL;
static E_Wizard_Page *curpage = NULL;
static int next_ok = 1;
static int next_can = 0;
static int next_prev = 0;
static Eina_Bool no_show = EINA_FALSE;
static Eina_Bool next_can = EINA_FALSE;
static Eina_List *handlers = NULL;
static Eina_Bool got_desktops = EINA_FALSE;
static Eina_Bool got_icons = EINA_FALSE;
static Eina_Bool next_need_xdg_desktops = EINA_FALSE;
static Eina_Bool next_need_xdg_icons = EINA_FALSE;
static Ecore_Timer *next_timer = NULL;
EAPI int
e_wizard_init(void)
@ -42,6 +55,12 @@ e_wizard_init(void)
}
}
}
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_DESKTOP_CACHE_BUILD,
_e_wizard_cb_desktops_update, NULL);
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_ICON_CACHE_UPDATE,
_e_wizard_cb_icons_update, NULL);
return 1;
}
@ -61,6 +80,10 @@ e_wizard_shutdown(void)
e_object_del(eo);
EINA_LIST_FREE(pages, pg)
e_wizard_page_del(pg);
if (next_timer) ecore_timer_del(next_timer);
next_timer = NULL;
E_FREE_LIST(handlers, ecore_event_handler_del);
return 1;
}
@ -72,16 +95,18 @@ e_wizard_go(void)
if (pages)
{
curpage = pages->data;
if (pages->next) next_can = 1;
}
}
if (curpage)
{
if ((!curpage->data) && (curpage->init)) curpage->init(curpage);
_e_wizard_next_eval();
int next;
if (curpage->init) curpage->init(curpage, &next_need_xdg_desktops, &next_need_xdg_icons);
next = _e_wizard_next_eval();
if ((curpage->show) && (!curpage->show(curpage)))
{
e_wizard_next();
if (next)
e_wizard_next();
}
}
}
@ -112,23 +137,30 @@ e_wizard_next(void)
{
if (eina_list_next(l))
{
int next;
if (curpage)
{
if (curpage->hide)
curpage->hide(curpage);
}
curpage = eina_list_data_get(eina_list_next(l));
if (!curpage->data)
{
if (curpage->init)
curpage->init(curpage);
}
next_can = 1;
_e_wizard_next_eval();
next_need_xdg_desktops = EINA_FALSE;
next_need_xdg_icons = EINA_FALSE;
if (curpage->init)
curpage->init(curpage, &next_need_xdg_desktops, &next_need_xdg_icons);
no_show = EINA_FALSE;
next = _e_wizard_next_eval();
if ((curpage->show) && (curpage->show(curpage)))
{
break;
}
if (!next)
{
no_show = EINA_TRUE;
/* Advance within 15 secs if no other trigger */
next_timer = ecore_timer_add(15.0, _e_wizard_cb_next_page, NULL);
break;
}
}
else
{
@ -161,7 +193,7 @@ e_wizard_page_show(Evas_Object *obj)
EAPI E_Wizard_Page *
e_wizard_page_add(void *handle,
int (*init_cb)(E_Wizard_Page *pg),
int (*init_cb)(E_Wizard_Page *pg, Eina_Bool *need_xdg_desktops, Eina_Bool *need_xdg_icons),
int (*shutdown_cb)(E_Wizard_Page *pg),
int (*show_cb)(E_Wizard_Page *pg),
int (*hide_cb)(E_Wizard_Page *pg),
@ -223,27 +255,51 @@ e_wizard_dir_get(void)
return e_module_dir_get(wiz_module);
}
static void
EAPI void
e_wizard_xdg_desktops_reset(void)
{
got_desktops = EINA_FALSE;
}
static int
_e_wizard_next_eval(void)
{
int ok;
ok = next_can;
if (next_timer) ecore_timer_del(next_timer);
next_timer = NULL;
ok = 1;
if (((next_need_xdg_desktops) && (!got_desktops)) ||
((next_need_xdg_icons) && (!got_icons)))
ok = 0;
if (!next_ok) ok = 0;
if (next_prev != ok)
{
if (ok)
{
edje_object_part_text_set(o_bg, "e.text.label", _("Next"));
edje_object_signal_emit(o_bg, "e,state,next,enable", "e");
}
{
if (no_show)
{
/* If we are waiting on a hidden page, continue */
e_wizard_next();
no_show = EINA_FALSE;
ok = -1;
}
else
{
edje_object_part_text_set(o_bg, "e.text.label", _("Next"));
edje_object_signal_emit(o_bg, "e,state,next,enable", "e");
}
}
else
{
edje_object_part_text_set(o_bg, "e.text.label", _("Please Wait..."));
edje_object_signal_emit(o_bg, "e,state,next,disable", "e");
}
{
edje_object_part_text_set(o_bg, "e.text.label", _("Please Wait..."));
edje_object_signal_emit(o_bg, "e,state,next,disable", "e");
}
next_prev = ok;
}
next_can = ok;
return ok;
}
static E_Popup *
@ -348,6 +404,34 @@ _e_wizard_cb_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *ob
static void
_e_wizard_cb_next(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
e_wizard_next();
/* TODO: Disable button in theme */
if (next_can)
e_wizard_next();
}
static Eina_Bool
_e_wizard_cb_next_page(void *data __UNUSED__)
{
next_timer = NULL;
next_need_xdg_desktops = EINA_FALSE;
next_need_xdg_icons = EINA_FALSE;
_e_wizard_next_eval();
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_e_wizard_cb_desktops_update(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
got_desktops = EINA_TRUE;
_e_wizard_next_eval();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_wizard_cb_icons_update(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
got_icons = EINA_TRUE;
_e_wizard_next_eval();
return ECORE_CALLBACK_PASS_ON;
}

View File

@ -10,12 +10,11 @@ struct _E_Wizard_Page
{
void *handle;
Evas *evas;
int (*init) (E_Wizard_Page *pg);
int (*init) (E_Wizard_Page *pg, Eina_Bool *need_xdg_desktops, Eina_Bool *need_xdg_icons);
int (*shutdown) (E_Wizard_Page *pg);
int (*show) (E_Wizard_Page *pg);
int (*hide) (E_Wizard_Page *pg);
int (*apply) (E_Wizard_Page *pg);
void *data;
};
EAPI int e_wizard_init(void);
@ -25,7 +24,7 @@ EAPI void e_wizard_apply(void);
EAPI void e_wizard_next(void);
EAPI void e_wizard_page_show(Evas_Object *obj);
EAPI E_Wizard_Page *e_wizard_page_add(void *handle,
int (*init) (E_Wizard_Page *pg),
int (*init) (E_Wizard_Page *pg, Eina_Bool *need_xdg_desktops, Eina_Bool *need_xdg_icons),
int (*shutdown) (E_Wizard_Page *pg),
int (*show) (E_Wizard_Page *pg),
int (*hide) (E_Wizard_Page *pg),
@ -36,6 +35,7 @@ EAPI void e_wizard_button_next_enable_set(int enable);
EAPI void e_wizard_title_set(const char *title);
EAPI void e_wizard_labels_update(void);
EAPI const char *e_wizard_dir_get(void);
EAPI void e_wizard_xdg_desktops_reset(void);
#endif
#endif

View File

@ -3,11 +3,10 @@
#include "e.h"
#include "e_mod_main.h"
static Ecore_Event_Handler *_update_handler = NULL;
static Ecore_Timer *_next_timer = NULL;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}
@ -15,8 +14,6 @@ wizard_page_init(E_Wizard_Page *pg __UNUSED__)
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
{
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
if (_next_timer) ecore_timer_del(_next_timer);
_next_timer = NULL;
return 1;
@ -26,23 +23,11 @@ static Eina_Bool
_next_page(void *data __UNUSED__)
{
_next_timer = NULL;
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
e_wizard_button_next_enable_set(1);
e_wizard_next();
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_cb_desktops_update(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
if (_next_timer) ecore_timer_del(_next_timer);
_next_timer = ecore_timer_add(2.0, _next_page, NULL);
return ECORE_CALLBACK_PASS_ON;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg __UNUSED__)
{
@ -54,12 +39,8 @@ wizard_page_show(E_Wizard_Page *pg __UNUSED__)
e_theme_edje_object_set(o, "base/theme/wizard", "e/wizard/firstpage");
e_wizard_page_show(o);
_update_handler =
ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_BUILD,
_cb_desktops_update, NULL);
/* advance in 15 sec anyway if no efreet update comes */
_next_timer = ecore_timer_add(15.0, _next_page, NULL);
/* advance in 1 sec */
_next_timer = ecore_timer_add(1.0, _next_page, NULL);
return 1;
}

View File

@ -82,7 +82,7 @@ _basic_lang_list_sort(const void *data1, const void *data2)
}
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
FILE *output;
@ -210,7 +210,10 @@ wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
/* special - language inits its stuff the moment it goes away */
eina_stringshare_del(e_config->language);
e_config->language = eina_stringshare_ref(lang);
/* TODO: This can trigger a efreet cache rebuild, need to wait until it is done */
/* TODO:
* This should be on lang select,
* so if next page needs xdg we can't press next */
e_wizard_xdg_desktops_reset();
e_intl_language_set(e_config->language);
e_wizard_labels_update();
return 1;

View File

@ -110,7 +110,7 @@ implement_layout(void)
}
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
// parse kbd rules here
find_rules();

View File

@ -29,7 +29,7 @@ _profile_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
}
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,7 +3,7 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -2,20 +2,18 @@
#include "e.h"
#include "e_mod_main.h"
static Ecore_Event_Handler *_update_handler = NULL;
static Ecore_Timer *_next_timer = NULL;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops, Eina_Bool *need_xdg_icons __UNUSED__)
{
*need_xdg_desktops = EINA_TRUE;
return 1;
}
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
{
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
if (_next_timer) ecore_timer_del(_next_timer);
_next_timer = NULL;
return 1;
@ -25,23 +23,11 @@ static Eina_Bool
_next_page(void *data __UNUSED__)
{
_next_timer = NULL;
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
e_wizard_button_next_enable_set(1);
e_wizard_next();
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_cb_desktops_update(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
{
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
if (_next_timer) ecore_timer_del(_next_timer);
_next_timer = ecore_timer_add(0.1, _next_page, NULL);
return ECORE_CALLBACK_PASS_ON;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg __UNUSED__)
{
@ -57,13 +43,8 @@ wizard_page_show(E_Wizard_Page *pg __UNUSED__)
snprintf(buf, sizeof(buf), "%s/extra_desktops", e_wizard_dir_get());
extra_desks = ecore_file_ls(buf);
_update_handler =
ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE,
_cb_desktops_update, NULL);
/* advance in 15 sec anyway if no efreet update comes */
_next_timer = ecore_timer_add(15.0, _next_page, NULL);
if (!extra_desks) return 1;
/* advance in 1 sec */
_next_timer = ecore_timer_add(1.0, _next_page, NULL);
EINA_LIST_FREE(extra_desks, file)
{
@ -127,8 +108,6 @@ wizard_page_show(E_Wizard_Page *pg __UNUSED__)
{
if (_next_timer) ecore_timer_del(_next_timer);
_next_timer = NULL;
if (_update_handler) ecore_event_handler_del(_update_handler);
_update_handler = NULL;
return 0; /* we didnt copy anything so advance anyway */
}
return 1; /* 1 == show ui, and wait for user, 0 == just continue */

View File

@ -6,7 +6,7 @@ static double scale = 1.0;
static Eina_List *obs = NULL;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -5,7 +5,7 @@
static int focus_mode = 1;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,8 +3,9 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons)
{
*need_xdg_icons = EINA_TRUE;
return 1;
}
@ -67,4 +68,3 @@ wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
{
return 1;
}

View File

@ -3,8 +3,9 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops, Eina_Bool *need_xdg_icons __UNUSED__)
{
*need_xdg_desktops = EINA_TRUE;
return 1;
}
@ -73,4 +74,3 @@ wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
{
return 1;
}

View File

@ -33,7 +33,7 @@ read_file(const char *file)
}
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -32,7 +32,7 @@ read_file(const char *file)
#endif
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -98,7 +98,7 @@ _check_connman_owner(void *data, DBusMessage *msg,
#endif
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -32,7 +32,7 @@
*/
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,7 +3,7 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,7 +3,7 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -48,7 +48,7 @@ match_xorg_log(const char *globbing)
}
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,7 +3,7 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -5,7 +5,7 @@
static int do_up = 1;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -5,7 +5,7 @@
static int do_tasks = 1;
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}

View File

@ -3,7 +3,7 @@
#include "e_mod_main.h"
EAPI int
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
{
return 1;
}