edje: automatically emit ['edje,change,file', 'edje'] when the file change on disk.

For the moment only edje_player use it. This means that when used with
edje_watch, you don't need any more to type any kind of command line
when you are testing value in your theme. As a side effect, this means
that their is a real use case to make edje_cc faster !



SVN revision: 70890
This commit is contained in:
Cedric BAIL 2012-05-09 09:16:52 +00:00
parent baffed6e81
commit b786fe1ced
12 changed files with 135 additions and 12 deletions

View File

@ -432,4 +432,5 @@
* Fix bug in case of nesting edje_object_signal_emit and edje_object_signal_callback_{add,del}
* Check that the file changed on disk when trying to reopen it.
* Emit ['edje,change,file', 'edje'] when the file change on disk.
* Automatically reload edje file when it change in edje_player.

View File

@ -5,6 +5,8 @@ Changes since Edje 1.2.0:
Additions:
* Add edje_watch to monitore change on edje source.
* Emit ['edje,change,file', 'edje'] when the file change on disk.
* edje_player will automatically reload the file when it change on disk.
Improvements:
* Allocate once and reuse Evas_Map.

View File

@ -37,6 +37,8 @@ struct opts {
char *title;
};
static Eina_Bool _edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group);
static Ecore_Evas *win;
static void
@ -456,6 +458,17 @@ _create_bg(Evas *evas, const struct opts *opts)
return bg;
}
static void
_edje_reload(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{
const char *file;
const char *group;
edje_object_signal_callback_del(obj, "edje,change,file", "edje", _edje_reload);
edje_object_file_get(obj, &file, &group);
_edje_load_or_show_error(obj, file, group);
}
static Eina_Bool
_edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group)
{
@ -464,6 +477,7 @@ _edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group)
if (edje_object_file_set(edje, file, group))
{
edje_object_signal_callback_add(edje, "edje,change,file", "edje", _edje_reload, NULL);;
evas_object_focus_set(edje, EINA_TRUE);
return EINA_TRUE;
}

View File

@ -116,6 +116,7 @@ main(int argc, char **argv)
fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command);
system(edje_cc_command);
read_watch_file(watchfile);
fprintf(stderr, "DONE\n");
ecore_main_loop_begin();

View File

@ -12,6 +12,7 @@ AM_CPPFLAGS = \
@EVIL_CFLAGS@ \
@EDJE_CFLAGS@ \
@ECORE_IMF_CFLAGS@ \
@EIO_CFLAGS@ \
@EFL_EDJE_BUILD@ \
@REMIX_CFLAGS@ \
@SNDFILE_CFLAGS@
@ -114,6 +115,10 @@ edje_amalgamation.c: $(base_sources) Makefile
@echo "# include <Ecore_IMF.h>" >> edje_amalgamation.c
@echo "#endif" >> edje_amalgamation.c
@echo "#ifdef HAVE_EIO" >> edje_amalgamation.c
@echo "# include <Eio.h>" >> edje_amalgamation.c
@echo "#endif" >> edje_amalgamation.c
@echo "#include <edje_private.h>" >> edje_amalgamation.c
@for f in $(base_sources); do \
@ -123,7 +128,7 @@ edje_amalgamation.c: $(base_sources) Makefile
file="$$f" ; \
fi ; \
echo "/* file: $$file */" >> edje_amalgamation.c; \
grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|Eet\|Evas\|Ecore\|Embryo\|Ecore_IMF\|string\|math\|limits\|sys/stat\|errno\|time\|unistd\|locale\|lua\|lauxlib\|edje_private\)[.]h.*' $$file >> edje_amalgamation.c; \
grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|Eet\|Evas\|Ecore\|Embryo\|Ecore_IMF\|Eio\|string\|math\|limits\|sys/stat\|errno\|time\|unistd\|locale\|lua\|lauxlib\|edje_private\)[.]h.*' $$file >> edje_amalgamation.c; \
done
@echo "edje_amalgamation.c generated"
@ -131,7 +136,7 @@ else
libedje_la_SOURCES = $(base_sources)
endif
libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm
libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EIO_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm
libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
EXTRA_DIST = edje_private.h edje_container.h edje_convert.h

View File

@ -127,12 +127,47 @@ _edje_file_coll_open(Edje_File *edf, const char *coll)
return edc;
}
#ifdef HAVE_EIO
static Eina_Bool
_edje_file_warn(void *data)
{
Edje_File *edf = data;
Eina_List *l, *ll;
Edje *ed;
EINA_LIST_FOREACH_SAFE(edf->edjes, l, ll, ed)
{
_edje_emit(ed, "edje,change,file", "edje");
}
edf->timeout = NULL;
return EINA_FALSE;
}
static Eina_Bool
_edje_file_change(void *data, int ev_type __UNUSED__, void *event)
{
Edje_File *edf = data;
Eio_Monitor_Event *ev = event;
if (ev->monitor == edf->monitor)
{
if (edf->timeout) ecore_timer_del(edf->timeout);
edf->timeout = ecore_timer_add(0.5, _edje_file_warn, edf);
}
return ECORE_CALLBACK_PASS_ON;
}
#endif
static Edje_File *
_edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, time_t mtime)
{
Edje_File *edf;
Edje_Part_Collection *edc;
Eet_File *ef;
#ifdef HAVE_EIO
Ecore_Event_Handler *ev;
#endif
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
@ -150,6 +185,17 @@ _edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Co
edf->ef = ef;
edf->mtime = mtime;
#ifdef HAVE_EIO
edf->monitor = eio_monitor_add(file);
ev = ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, _edje_file_change, edf);
edf->handlers = eina_list_append(edf->handlers, ev);
ev = ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _edje_file_change, edf);
edf->handlers = eina_list_append(edf->handlers, ev);
ev = ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, _edje_file_change, edf);
edf->handlers = eina_list_append(edf->handlers, ev);
ev = ecore_event_handler_add(EIO_MONITOR_SELF_DELETED, _edje_file_change, edf);
edf->handlers = eina_list_append(edf->handlers, ev);
#endif
if (edf->version != EDJE_FILE_VERSION)
{
@ -203,7 +249,7 @@ _edje_file_dangling(Edje_File *edf)
}
Edje_File *
_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret)
_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed)
{
Edje_File *edf;
Eina_List *l, *hist;
@ -259,6 +305,12 @@ open_new:
if (!edf)
return NULL;
#ifdef HAVE_EIO
if (ed) edf->edjes = eina_list_append(edf->edjes, ed);
#else
(void) ed;
#endif
eina_hash_add(_edje_file_hash, file, edf);
return edf;
@ -364,6 +416,12 @@ open:
edc->checked = 1;
}
}
#ifdef HAVE_EIO
if (edc && ed) edf->edjes = eina_list_append(edf->edjes, ed);
#else
(void) ed;
#endif
if (edc_ret) *edc_ret = edc;
return edf;

View File

@ -89,7 +89,7 @@ edje_file_collection_list(const char *file)
int error_ret = 0;
if ((!file) || (!*file)) return NULL;
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL, NULL);
if (edf)
{
Eina_Iterator *i;
@ -129,7 +129,7 @@ edje_file_group_exists(const char *file, const char *glob)
if ((!file) || (!*file) || (!glob))
return EINA_FALSE;
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL, NULL);
if (!edf)
return EINA_FALSE;
@ -189,7 +189,7 @@ edje_file_data_get(const char *file, const char *key)
if (key)
{
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL, NULL);
if (edf)
{
str = (char*) edje_string_get(eina_hash_find(edf->data, key));
@ -902,7 +902,8 @@ _edje_file_add(Edje *ed)
if (!_edje_edd_edje_file) return;
ed->file = _edje_cache_file_coll_open(ed->path, ed->group,
&(ed->load_error),
&(ed->collection));
&(ed->collection),
ed);
if (!ed->collection)
{
@ -1055,7 +1056,10 @@ _edje_file_del(Edje *ed)
}
if (ed->file)
{
_edje_cache_file_unref(ed->file);
#ifdef HAVE_EIO
ed->file->edjes = eina_list_remove(ed->file->edjes, ed);
#endif
_edje_cache_file_unref(ed->file);
ed->file = NULL;
}
if (ed->actions)
@ -1096,6 +1100,9 @@ void
_edje_file_free(Edje_File *edf)
{
Edje_Color_Class *ecc;
#ifdef HAVE_EIO
Ecore_Event_Handler *event;
#endif
#define HASH_FREE(Hash) \
if (Hash) eina_hash_free(Hash); \
@ -1165,6 +1172,12 @@ _edje_file_free(Edje_File *edf)
}
if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns);
#ifdef HAVE_EIO
if (edf->timeout) ecore_timer_del(edf->timeout);
EINA_LIST_FREE(edf->handlers, event)
ecore_event_handler_del(event);
eio_monitor_del(edf->monitor);
#endif
if (edf->path) eina_stringshare_del(edf->path);
if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler);
_edje_textblock_style_cleanup(edf);

View File

@ -50,6 +50,14 @@ edje_init(void)
goto shutdown_embryo;
}
#ifdef HAVE_EIO
if (!eio_init())
{
ERR("Eio init failed");
goto shutdown_eet;
}
#endif
_edje_scale = FROM_DOUBLE(1.0);
_edje_edd_init();
@ -66,7 +74,7 @@ edje_init(void)
if (!_edje_real_part_mp)
{
ERR("Mempool for Edje_Real_Part cannot be allocated.");
goto shutdown_eet;
goto shutdown_all;
}
_edje_real_part_state_mp = eina_mempool_add("chained_mempool",
@ -75,12 +83,12 @@ edje_init(void)
if (!_edje_real_part_state_mp)
{
ERR("Mempool for Edje_Real_Part_State cannot be allocated.");
goto shutdown_eet;
goto shutdown_all;
}
return _edje_init_count;
shutdown_eet:
shutdown_all:
eina_mempool_del(_edje_real_part_state_mp);
eina_mempool_del(_edje_real_part_mp);
_edje_real_part_state_mp = NULL;
@ -92,6 +100,10 @@ edje_init(void)
_edje_text_class_members_free();
_edje_text_class_hash_free();
_edje_edd_shutdown();
#ifdef HAVE_EIO
eio_shutdown();
shutdown_eet:
#endif
eet_shutdown();
shutdown_embryo:
embryo_shutdown();
@ -130,6 +142,9 @@ _edje_shutdown_core(void)
_edje_text_class_hash_free();
_edje_edd_shutdown();
#ifdef HAVE_EIO
eio_shutdown();
#endif
eet_shutdown();
embryo_shutdown();
ecore_shutdown();

View File

@ -74,6 +74,10 @@ void *alloca (size_t);
#endif
#include <Embryo.h>
#ifdef HAVE_EIO
# include <Eio.h>
#endif
#include "Edje.h"
EAPI extern int _edje_default_log_dom ;
@ -466,6 +470,13 @@ struct _Edje_File
Eet_File *ef;
#ifdef HAVE_EIO
Eio_Monitor *monitor;
Eina_List *edjes;
Eina_List *handlers;
Ecore_Timer *timeout;
#endif
unsigned char free_strings : 1;
unsigned char dangling : 1;
unsigned char warning : 1;

View File

@ -9,6 +9,7 @@ AM_CPPFLAGS = \
-DPACKAGE_LIB_DIR=\"$(libdir)/remix\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/remix\" \
@EDJE_CFLAGS@ \
@EIO_CFLAGS@ \
@REMIX_CFLAGS@ \
@ALSA_CFLAGS@

View File

@ -7,6 +7,7 @@ AM_CPPFLAGS = \
-DPACKAGE_LIB_DIR=\"$(libdir)/remix\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/remix\" \
@EDJE_CFLAGS@ \
@EIO_CFLAGS@ \
@REMIX_CFLAGS@
pkgdir = $(REMIX_PLUGIN_DIR)

View File

@ -11,6 +11,7 @@ AM_CPPFLAGS = \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-DPACKAGE_EXAMPLES_DIR=\"$(datadir)/$(PACKAGE)/multisense_factory\" \
@EDJE_CFLAGS@ \
@EIO_CFLAGS@ \
@REMIX_CFLAGS@
pkgdir = $(libdir)/edje/modules/multisense_factory/$(MODULE_ARCH)