2004-10-26 12:01:17 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
2008-10-26 10:18:19 -07:00
|
|
|
#include <time.h>
|
|
|
|
|
2003-06-02 16:49:56 -07:00
|
|
|
#include "edje_private.h"
|
|
|
|
|
2009-10-08 00:05:19 -07:00
|
|
|
static int _edje_init_count = 0;
|
2009-10-08 22:41:05 -07:00
|
|
|
static int _edje_log_dom_global = -1;
|
2009-08-14 10:19:42 -07:00
|
|
|
Eina_Mempool *_edje_real_part_mp = NULL;
|
|
|
|
Eina_Mempool *_edje_real_part_state_mp = NULL;
|
2004-01-12 09:41:48 -08:00
|
|
|
|
2009-10-08 22:41:05 -07:00
|
|
|
#ifdef EDJE_DEFAULT_LOG_COLOR
|
|
|
|
# undef EDJE_DEFAULT_LOG_COLOR
|
|
|
|
#endif
|
|
|
|
#define EDJE_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
|
|
|
|
#ifdef ERR
|
|
|
|
# undef ERR
|
|
|
|
#endif
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_edje_log_dom_global, __VA_ARGS__)
|
|
|
|
|
2004-06-05 21:42:17 -07:00
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Edje_main_Group Main
|
|
|
|
*
|
|
|
|
* @brief These functions provide an abstraction layer between the
|
|
|
|
* application code and the interface, while allowing extremely
|
|
|
|
* flexible dynamic layouts and animations.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize the edje library.
|
|
|
|
*
|
|
|
|
* @return The new init count. The initial value is zero.
|
|
|
|
*
|
|
|
|
* This function initializes the ejde library, making the propers
|
|
|
|
* calls to initialization functions. It makes calls to functions
|
|
|
|
* eina_init(), ecore_job_init(), embryo_init() and eet_init() so
|
|
|
|
* there is no need to call those functions again in your code. To
|
|
|
|
* shutdown edje there is a function edje_shutdown().
|
|
|
|
*
|
|
|
|
* @see edje_shutdown()
|
|
|
|
* @see eina_init()
|
|
|
|
* @see ecore_job_init()
|
|
|
|
* @see embryo_init()
|
|
|
|
* @see eet_init()
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI int
|
2003-06-17 01:15:06 -07:00
|
|
|
edje_init(void)
|
|
|
|
{
|
2009-10-08 00:05:19 -07:00
|
|
|
if (++_edje_init_count != 1)
|
|
|
|
return _edje_init_count;
|
|
|
|
|
|
|
|
srand(time(NULL));
|
2009-10-08 14:58:32 -07:00
|
|
|
|
|
|
|
if (!eina_init())
|
2009-10-08 22:41:05 -07:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Edje: Eina init failed");
|
|
|
|
return --_edje_init_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
_edje_log_dom_global = eina_log_domain_register("Edje", EDJE_DEFAULT_LOG_COLOR);
|
|
|
|
if (_edje_log_dom_global < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Edje Can not create a general log domain.");
|
|
|
|
goto shutdown_eina;
|
|
|
|
}
|
|
|
|
|
2009-10-08 14:58:32 -07:00
|
|
|
if (!ecore_job_init())
|
2009-10-08 22:41:05 -07:00
|
|
|
{
|
|
|
|
ERR("Edje: Ecore_Job init failed");
|
|
|
|
goto unregister_log_domain;
|
|
|
|
}
|
|
|
|
|
2009-10-08 14:58:32 -07:00
|
|
|
if (!embryo_init())
|
2009-10-08 22:41:05 -07:00
|
|
|
{
|
|
|
|
ERR("Edje: Embryo init failed");
|
|
|
|
goto shutdown_ecore_job;
|
|
|
|
}
|
|
|
|
|
2009-10-08 14:58:32 -07:00
|
|
|
if (!eet_init())
|
2009-10-08 22:41:05 -07:00
|
|
|
{
|
|
|
|
ERR("Edje: Eet init failed");
|
|
|
|
goto shutdown_embryo;
|
|
|
|
}
|
2009-10-08 14:58:32 -07:00
|
|
|
|
2009-10-08 22:17:19 -07:00
|
|
|
_edje_edd_init();
|
2009-10-08 00:05:19 -07:00
|
|
|
_edje_text_init();
|
|
|
|
_edje_box_init();
|
|
|
|
_edje_lua_init();
|
2009-10-08 14:58:32 -07:00
|
|
|
_edje_message_init();
|
2009-10-08 00:05:19 -07:00
|
|
|
|
|
|
|
_edje_real_part_mp = eina_mempool_add("chained_mempool",
|
|
|
|
"Edje_Real_Part", NULL,
|
|
|
|
sizeof (Edje_Real_Part), 128);
|
|
|
|
if (!_edje_real_part_mp)
|
2004-01-19 17:04:16 -08:00
|
|
|
{
|
2009-10-08 22:41:05 -07:00
|
|
|
ERR("ERROR: Mempool for Edje_Real_Part cannot be allocated.\n");
|
2009-10-08 14:58:32 -07:00
|
|
|
goto shutdown_eet;
|
2004-01-19 17:04:16 -08:00
|
|
|
}
|
2009-10-08 00:05:19 -07:00
|
|
|
|
|
|
|
_edje_real_part_state_mp = eina_mempool_add("chained_mempool",
|
|
|
|
"Edje_Real_Part_State", NULL,
|
|
|
|
sizeof (Edje_Real_Part_State), 256);
|
|
|
|
if (!_edje_real_part_state_mp)
|
|
|
|
{
|
2009-10-08 22:41:05 -07:00
|
|
|
ERR("ERROR: Mempool for Edje_Real_Part_State cannot be allocated.\n");
|
2009-10-08 14:58:32 -07:00
|
|
|
goto shutdown_eet;
|
2009-10-08 00:05:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return _edje_init_count;
|
2009-08-14 10:19:42 -07:00
|
|
|
|
2009-10-08 14:58:32 -07:00
|
|
|
shutdown_eet:
|
2009-08-14 10:19:42 -07:00
|
|
|
eina_mempool_del(_edje_real_part_state_mp);
|
|
|
|
eina_mempool_del(_edje_real_part_mp);
|
|
|
|
_edje_real_part_state_mp = NULL;
|
|
|
|
_edje_real_part_mp = NULL;
|
2009-10-08 14:58:32 -07:00
|
|
|
_edje_message_shutdown();
|
|
|
|
_edje_lua_shutdown();
|
|
|
|
_edje_box_shutdown();
|
|
|
|
_edje_text_class_members_free();
|
|
|
|
_edje_text_class_hash_free();
|
2009-10-08 22:17:19 -07:00
|
|
|
_edje_edd_shutdown();
|
2009-10-08 14:58:32 -07:00
|
|
|
eet_shutdown();
|
|
|
|
shutdown_embryo:
|
|
|
|
embryo_shutdown();
|
|
|
|
shutdown_ecore_job:
|
|
|
|
ecore_job_shutdown();
|
2009-10-08 22:41:05 -07:00
|
|
|
unregister_log_domain:
|
|
|
|
eina_log_domain_unregister(_edje_log_dom_global);
|
|
|
|
_edje_log_dom_global = -1;
|
2009-10-08 14:58:32 -07:00
|
|
|
shutdown_eina:
|
|
|
|
eina_shutdown();
|
|
|
|
return --_edje_init_count;
|
2003-06-17 01:15:06 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Shutdown the edje library.
|
|
|
|
*
|
2009-10-08 00:05:19 -07:00
|
|
|
* @return The number of times the library has been initialised without being
|
|
|
|
* shutdown.
|
2009-09-17 15:38:35 -07:00
|
|
|
*
|
|
|
|
* This function shuts down the edje library. It calls the functions
|
|
|
|
* eina_shutdown(), ecore_job_shutdown(), embryo_shutdown() and
|
|
|
|
* eet_shutdown(), so there is no need to call these functions again
|
|
|
|
* in your code.
|
|
|
|
*
|
|
|
|
* @see edje_init()
|
|
|
|
* @see eina_shutdown()
|
|
|
|
* @see ecore_job_shutdown()
|
|
|
|
* @see embryo_shutdown()
|
|
|
|
* @see eet_shutdown()
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI int
|
2004-01-12 09:41:48 -08:00
|
|
|
edje_shutdown(void)
|
|
|
|
{
|
2009-10-08 00:05:19 -07:00
|
|
|
if (--_edje_init_count != 0)
|
|
|
|
return _edje_init_count;
|
2004-01-12 09:41:48 -08:00
|
|
|
|
2007-10-04 22:12:38 -07:00
|
|
|
if (_edje_timer)
|
|
|
|
ecore_animator_del(_edje_timer);
|
|
|
|
_edje_timer = NULL;
|
|
|
|
|
2005-04-03 04:43:00 -07:00
|
|
|
_edje_file_cache_shutdown();
|
2004-01-12 11:21:25 -08:00
|
|
|
_edje_color_class_members_free();
|
2005-01-12 22:29:52 -08:00
|
|
|
_edje_color_class_hash_free();
|
2009-08-14 10:19:42 -07:00
|
|
|
|
|
|
|
eina_mempool_del(_edje_real_part_state_mp);
|
|
|
|
eina_mempool_del(_edje_real_part_mp);
|
|
|
|
_edje_real_part_state_mp = NULL;
|
|
|
|
_edje_real_part_mp = NULL;
|
|
|
|
|
2009-10-08 14:58:32 -07:00
|
|
|
_edje_message_shutdown();
|
|
|
|
_edje_lua_shutdown();
|
|
|
|
_edje_box_shutdown();
|
|
|
|
_edje_text_class_members_free();
|
|
|
|
_edje_text_class_hash_free();
|
2009-10-08 22:17:19 -07:00
|
|
|
_edje_edd_shutdown();
|
2009-10-08 14:58:32 -07:00
|
|
|
|
2009-10-08 00:05:19 -07:00
|
|
|
eet_shutdown();
|
2004-03-29 04:00:01 -08:00
|
|
|
embryo_shutdown();
|
2007-10-04 22:12:38 -07:00
|
|
|
ecore_job_shutdown();
|
2009-10-08 22:41:05 -07:00
|
|
|
eina_log_domain_unregister(_edje_log_dom_global);
|
|
|
|
_edje_log_dom_global = -1;
|
2008-10-15 07:11:11 -07:00
|
|
|
eina_shutdown();
|
2008-03-24 01:22:01 -07:00
|
|
|
|
2009-10-08 00:05:19 -07:00
|
|
|
return _edje_init_count;
|
2004-01-12 09:41:48 -08:00
|
|
|
}
|
|
|
|
|
2004-06-05 21:42:17 -07:00
|
|
|
/* Private Routines */
|
|
|
|
|
2003-06-18 07:20:26 -07:00
|
|
|
Edje *
|
|
|
|
_edje_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Edje *ed;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-18 07:20:26 -07:00
|
|
|
ed = calloc(1, sizeof(Edje));
|
|
|
|
if (!ed) return NULL;
|
|
|
|
ed->evas = evas_object_evas_get(obj);
|
|
|
|
ed->clipper = evas_object_rectangle_add(ed->evas);
|
|
|
|
evas_object_smart_member_add(ed->clipper, obj);
|
|
|
|
evas_object_color_set(ed->clipper, 255, 255, 255, 255);
|
2004-05-17 21:21:22 -07:00
|
|
|
evas_object_move(ed->clipper, -10000, -10000);
|
|
|
|
evas_object_resize(ed->clipper, 20000, 20000);
|
2003-06-26 07:04:31 -07:00
|
|
|
evas_object_pass_events_set(ed->clipper, 1);
|
|
|
|
ed->have_objects = 1;
|
|
|
|
ed->references = 1;
|
2003-06-18 07:20:26 -07:00
|
|
|
return ed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_del(Edje *ed)
|
|
|
|
{
|
2005-07-28 06:39:23 -07:00
|
|
|
if (ed->processing_messages)
|
|
|
|
{
|
|
|
|
ed->delete_me = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_edje_message_del(ed);
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_clean(ed);
|
2003-06-19 07:43:49 -07:00
|
|
|
_edje_file_del(ed);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (ed->path) eina_stringshare_del(ed->path);
|
|
|
|
if (ed->group) eina_stringshare_del(ed->group);
|
|
|
|
if (ed->parent) eina_stringshare_del(ed->parent);
|
2005-11-30 01:56:15 -08:00
|
|
|
ed->path = NULL;
|
2008-08-14 11:04:43 -07:00
|
|
|
ed->group = NULL;
|
2004-03-07 18:43:48 -08:00
|
|
|
if ((ed->actions) || (ed->pending_actions))
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
_edje_animators = eina_list_remove(_edje_animators, ed);
|
2004-03-07 18:43:48 -08:00
|
|
|
}
|
|
|
|
while (ed->actions)
|
|
|
|
{
|
|
|
|
Edje_Running_Program *runp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
runp = eina_list_data_get(ed->actions);
|
|
|
|
ed->actions = eina_list_remove(ed->actions, runp);
|
2004-03-07 18:43:48 -08:00
|
|
|
free(runp);
|
|
|
|
}
|
|
|
|
while (ed->pending_actions)
|
|
|
|
{
|
|
|
|
Edje_Pending_Program *pp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
pp = eina_list_data_get(ed->pending_actions);
|
|
|
|
ed->pending_actions = eina_list_remove(ed->pending_actions, pp);
|
2004-03-07 18:43:48 -08:00
|
|
|
free(pp);
|
|
|
|
}
|
2003-06-26 07:04:31 -07:00
|
|
|
while (ed->callbacks)
|
|
|
|
{
|
|
|
|
Edje_Signal_Callback *escb;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
escb = eina_list_data_get(ed->callbacks);
|
|
|
|
ed->callbacks = eina_list_remove(ed->callbacks, escb);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (escb->signal) eina_stringshare_del(escb->signal);
|
|
|
|
if (escb->source) eina_stringshare_del(escb->source);
|
2003-06-26 07:04:31 -07:00
|
|
|
free(escb);
|
|
|
|
}
|
2003-07-12 19:06:46 -07:00
|
|
|
while (ed->color_classes)
|
|
|
|
{
|
2003-10-29 20:45:18 -08:00
|
|
|
Edje_Color_Class *cc;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
cc = eina_list_data_get(ed->color_classes);
|
|
|
|
ed->color_classes = eina_list_remove(ed->color_classes, cc);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (cc->name) eina_stringshare_del(cc->name);
|
2003-07-12 19:06:46 -07:00
|
|
|
free(cc);
|
|
|
|
}
|
|
|
|
while (ed->text_classes)
|
|
|
|
{
|
2003-10-29 20:45:18 -08:00
|
|
|
Edje_Text_Class *tc;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
tc = eina_list_data_get(ed->text_classes);
|
|
|
|
ed->text_classes = eina_list_remove(ed->text_classes, tc);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (tc->name) eina_stringshare_del(tc->name);
|
|
|
|
if (tc->font) eina_stringshare_del(tc->font);
|
2003-07-12 19:06:46 -07:00
|
|
|
free(tc);
|
|
|
|
}
|
2003-06-18 07:20:26 -07:00
|
|
|
free(ed);
|
|
|
|
}
|
2003-06-26 07:04:31 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
_edje_clean_objects(Edje *ed)
|
|
|
|
{
|
|
|
|
evas_object_del(ed->clipper);
|
|
|
|
ed->evas = NULL;
|
|
|
|
ed->obj = NULL;
|
|
|
|
ed->clipper = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_ref(Edje *ed)
|
|
|
|
{
|
2005-09-30 21:15:15 -07:00
|
|
|
if (ed->references <= 0) return;
|
2003-06-26 07:04:31 -07:00
|
|
|
ed->references++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_unref(Edje *ed)
|
|
|
|
{
|
|
|
|
ed->references--;
|
2005-09-30 21:15:15 -07:00
|
|
|
if (ed->references == 0) _edje_del(ed);
|
2003-06-26 07:04:31 -07:00
|
|
|
}
|
2009-09-28 23:13:33 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|