summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-11-25 15:16:02 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-11-25 16:48:44 +0200
commita6f2deeaa3910e624ba5cce8656aa58eea9f5ba5 (patch)
tree42b0f5fc5ca6f09b8492a307c77956d1c69250b4 /src/bin
parente637a4ac8cd2597b4e5f3649a5e3a2e3c84950ad (diff)
edc: fix monitoring of edc files.
The mechanism is no more connected to Enventor.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/editor.c62
-rw-r--r--src/bin/egui_gui/rmview.c55
2 files changed, 64 insertions, 53 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index a9c7a78..9f1f322 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -1,3 +1,4 @@
1#include <libgen.h>
1 2
2#include "egui_log.h" 3#include "egui_log.h"
3#include "ffi_glue.h" 4#include "ffi_glue.h"
@@ -873,9 +874,70 @@ _win_resize(void *data EINA_UNUSED, Eo *o, const Eo_Event_Description *desc EINA
873 return EO_CALLBACK_CONTINUE; 874 return EO_CALLBACK_CONTINUE;
874} 875}
875 876
877static void
878_edc_file_updated(void *data, Ecore_File_Monitor *em EINA_UNUSED, Ecore_File_Event event, const char *file_path)
879{
880 Gui_Resource *res = data;
881
882 switch (event)
883 {
884 case ECORE_FILE_EVENT_MODIFIED:
885 {
886 Eina_Stringshare *path = gui_context_project_path_get(resource_context_get(res));
887 Eina_Strbuf *strbuf = eina_strbuf_new();
888 const char *edc_file = resource_edc_path_get(res);
889
890 eina_strbuf_append_printf(strbuf, "edje_cc -fastcomp %s %s", edc_file, resource_value_get(res));
891 eina_strbuf_append_printf(strbuf, " -id %s/images", path);
892 eina_strbuf_append_printf(strbuf, " -sd %s/sounds", path);
893 eina_strbuf_append_printf(strbuf, " -fd %s/fonts", path);
894 eina_strbuf_append_printf(strbuf, " -dd %s/data", path);
895
896 remove(resource_value_get(res));
897 system(eina_strbuf_string_get(strbuf));
898 /* we update the observers only if the invocation is from the system and not from _widget_prop_add */
899 if (file_path) gui_context_dep_observers_invoke(resource_dep_id_get(res));
900 break;
901 }
902 default:
903 break;
904 }
905}
906
876static Eina_Bool 907static Eina_Bool
877_widget_prop_add(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data EINA_UNUSED) 908_widget_prop_add(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data EINA_UNUSED)
878{ 909{
910 if (IS_LAYOUT(wdg) && !strcmp(prop_name_get(prop), FILE_SET))
911 {
912 Gui_Value *v = prop_value_nth_get(prop, 0);
913 Dep_Id *res_id = DEP_ID_GET(v);
914 Gui_Resource *res = (Gui_Resource *)gui_context_resource_get(res_id);
915 if (resource_type_get(res) == RESOURCE_EDJE)
916 {
917 const char *edc_file = resource_edc_path_get(res);
918 if (edc_file)
919 {
920 if (!strcmp(resource_value_get(res), resource_edj_path_get(res)))
921 {
922 Eina_Strbuf *buf = eina_strbuf_new();
923 char *edj_file = strdup(edc_file);
924 char *edj_name = basename(edj_file);
925 eina_strbuf_append_printf(buf, "/tmp/%s_%d.edj", edj_name, getpid());
926 resource_value_set(res, eina_strbuf_string_get(buf));
927 free(edj_file);
928 eina_strbuf_free(buf);
929 }
930
931 Ecore_File_Monitor *mon = resource_edc_monitor_get(res);
932 if (mon) ecore_file_monitor_del(mon);
933
934 mon = ecore_file_monitor_add(edc_file, _edc_file_updated, res);
935 resource_edc_monitor_set(res, mon);
936
937 _edc_file_updated(res, mon, ECORE_FILE_EVENT_MODIFIED, NULL);
938 }
939 }
940 }
879 Eina_Bool ret = _ffi_eo_do(session, wdg, prop); 941 Eina_Bool ret = _ffi_eo_do(session, wdg, prop);
880 942
881 if (IS_MAIN(wdg)) 943 if (IS_MAIN(wdg))
diff --git a/src/bin/egui_gui/rmview.c b/src/bin/egui_gui/rmview.c
index d583e60..dd321e7 100644
--- a/src/bin/egui_gui/rmview.c
+++ b/src/bin/egui_gui/rmview.c
@@ -1,7 +1,3 @@
1#ifdef HAVE_ENVENTOR
2#include <libgen.h>
3#endif
4
5#include <Elementary.h> 1#include <Elementary.h>
6#include "egui_log.h" 2#include "egui_log.h"
7#include "egui_layout.h" 3#include "egui_layout.h"
@@ -241,46 +237,6 @@ _res_changed(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc E
241} 237}
242 238
243#ifdef HAVE_ENVENTOR 239#ifdef HAVE_ENVENTOR
244static void
245_enventor_edc_file_updated(void *data, Ecore_File_Monitor *em EINA_UNUSED, Ecore_File_Event event, const char *file_path EINA_UNUSED)
246{
247 Gui_Resource *res = data;
248
249 switch (event)
250 {
251 case ECORE_FILE_EVENT_MODIFIED:
252 {
253 Eina_Stringshare *path = gui_context_project_path_get(resource_context_get(res));
254 Eina_Strbuf *strbuf = eina_strbuf_new();
255 const char *edc_file = resource_edc_path_get(res);
256
257 if (strcmp(resource_value_get(res), resource_edj_path_get(res)))
258 {
259 Eina_Strbuf *buf = eina_strbuf_new();
260 char *edj_file = strdup(edc_file);
261 char *edj_name = basename(edj_file);
262 eina_strbuf_append_printf(buf, "/tmp/%s_%d.edj", edj_name, getpid());
263 resource_value_set(res, eina_strbuf_string_get(buf));
264 free(edj_file);
265 eina_strbuf_free(buf);
266 }
267
268 remove(resource_value_get(res));
269 eina_strbuf_append_printf(strbuf, "edje_cc -fastcomp %s %s", edc_file, resource_value_get(res));
270 eina_strbuf_append_printf(strbuf, " -id %s/images", path);
271 eina_strbuf_append_printf(strbuf, " -sd %s/sounds", path);
272 eina_strbuf_append_printf(strbuf, " -fd %s/fonts", path);
273 eina_strbuf_append_printf(strbuf, " -dd %s/data", path);
274
275 system(eina_strbuf_string_get(strbuf));
276 gui_context_dep_observers_invoke(resource_dep_id_get(res));
277 break;
278 }
279 default:
280 break;
281 }
282}
283
284static Eina_Bool 240static Eina_Bool
285_enventor_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 241_enventor_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
286{ 242{
@@ -302,7 +258,6 @@ _enventor_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *d
302 258
303 ecore_exe_pipe_run(eina_strbuf_string_get(strbuf), flags, NULL); 259 ecore_exe_pipe_run(eina_strbuf_string_get(strbuf), flags, NULL);
304 260
305 ecore_file_monitor_add(edc_file, _enventor_edc_file_updated, f_data->it_data->res);
306 //printf("%s\n", eina_strbuf_string_get(strbuf)); 261 //printf("%s\n", eina_strbuf_string_get(strbuf));
307 eina_strbuf_free(strbuf); 262 eina_strbuf_free(strbuf);
308 } 263 }
@@ -363,16 +318,10 @@ _bt_save_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *de
363 eo_do(f_data->it_data->en2, elm_interface_fileselector_path_set(resource_edj_path_get(res))); 318 eo_do(f_data->it_data->en2, elm_interface_fileselector_path_set(resource_edj_path_get(res)));
364 } 319 }
365 eo_do(f_data->it_data->en3, str = elm_interface_fileselector_path_get()); 320 eo_do(f_data->it_data->en3, str = elm_interface_fileselector_path_get());
366 if (strlen(str)) 321 resource_edc_path_set(res, str);
367 {
368 resource_edc_path_set(res, str);
369 }
370 else
371 {
372 eo_do(f_data->it_data->en3, elm_interface_fileselector_path_set(resource_edc_path_get(res)));
373 }
374 const Gui_Widget *wdg = gui_context_data_get(ctx, SELECTED_WDG); 322 const Gui_Widget *wdg = gui_context_data_get(ctx, SELECTED_WDG);
375 proplayout_build(wdg); 323 proplayout_build(wdg);
324 gui_context_dep_observers_invoke(resource_dep_id_get(res));
376 } 325 }
377 /* For CALLBACKS and STRINGS. */ 326 /* For CALLBACKS and STRINGS. */
378 else 327 else