summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWonki Kim <wonki_.kim@samsung.com>2018-12-14 12:09:29 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2018-12-14 12:34:01 +0200
commit79c2e469fc3af266fa8d27134592c4bf2195bfae (patch)
tree966a266f2a0e660642f386eaa9a1401184beaa93
parent413f1c127d7786ba418555194e08c56957b88957 (diff)
GUI: modify gui to manage 'db' files
Summary: included patches modify gui to manage 'db' files in gui. Reviewers: JackDanielZ Reviewed By: JackDanielZ Differential Revision: https://phab.enlightenment.org/D7300
-rw-r--r--data/themes/layout.edc26
-rw-r--r--src/bin/db.c1
-rw-r--r--src/bin/gen.h1
-rw-r--r--src/bin/gui.c358
-rw-r--r--src/bin/main.c1
5 files changed, 294 insertions, 93 deletions
diff --git a/data/themes/layout.edc b/data/themes/layout.edc
index aaaf5fa..b176c18 100644
--- a/data/themes/layout.edc
+++ b/data/themes/layout.edc
@@ -393,3 +393,29 @@ group { "settings_layout";
393 } 393 }
394 } 394 }
395 } 395 }
396
397 group { "db_ctrl_layout";
398 parts {
399 spacer { "base";
400 scale;
401 nomouse;
402 desc { "default";
403 }
404 }
405 swallow { "swallow_left";
406 scale;
407 desc { "default";
408 rel1.relative: 0.0 0.0;
409 rel2.relative: 0.5 1.0;
410 fixed: 1 1;
411 }
412 }
413 swallow { "swallow_right";
414 scale;
415 desc { "default";
416 rel1.relative: 0.5 0.0;
417 rel2.relative: 1.0 1.0;
418 }
419 }
420 }
421 } \ No newline at end of file
diff --git a/src/bin/db.c b/src/bin/db.c
index 1eef56c..3eb931f 100644
--- a/src/bin/db.c
+++ b/src/bin/db.c
@@ -557,6 +557,7 @@ _wdg_free(_Widget *w)
557 _Wdg_Function *wf; 557 _Wdg_Function *wf;
558 _Parameter *p; 558 _Parameter *p;
559 _Event *act; 559 _Event *act;
560 if (!w) return;
560 EINA_LIST_FREE(w->children_configs, wc) 561 EINA_LIST_FREE(w->children_configs, wc)
561 { 562 {
562 _Wdg_Children_Config_Item *wci; 563 _Wdg_Children_Config_Item *wci;
diff --git a/src/bin/gen.h b/src/bin/gen.h
index 0afc521..b6ceb70 100644
--- a/src/bin/gen.h
+++ b/src/bin/gen.h
@@ -11,6 +11,7 @@ typedef struct
11 Eina_List *mls_paths; 11 Eina_List *mls_paths;
12 Eina_List *units_paths; 12 Eina_List *units_paths;
13 Eina_List *validated_paths; 13 Eina_List *validated_paths;
14 Eina_List *dbs_paths;
14 char *efl_install_dir; 15 char *efl_install_dir;
15 char *efl_repo_dir; 16 char *efl_repo_dir;
16 char *font_name; 17 char *font_name;
diff --git a/src/bin/gui.c b/src/bin/gui.c
index 7d4db34..3f30013 100644
--- a/src/bin/gui.c
+++ b/src/bin/gui.c
@@ -27,8 +27,6 @@
27 SWAP_32(__i); \ 27 SWAP_32(__i); \
28}) 28})
29 29
30static Ea_DB *_db = NULL;
31
32static int _cl_stat_reg_op = EINA_DEBUG_OPCODE_INVALID; 30static int _cl_stat_reg_op = EINA_DEBUG_OPCODE_INVALID;
33static int _app_take_shot_op = EINA_DEBUG_OPCODE_INVALID; 31static int _app_take_shot_op = EINA_DEBUG_OPCODE_INVALID;
34static int _app_finish_op = EINA_DEBUG_OPCODE_INVALID; 32static int _app_finish_op = EINA_DEBUG_OPCODE_INVALID;
@@ -105,6 +103,7 @@ typedef struct
105{ 103{
106 _App_Status status; 104 _App_Status status;
107 Exactness_Image icon; 105 Exactness_Image icon;
106 Ea_DB *db;
108 Eo *item; 107 Eo *item;
109 Eina_Strbuf *exe_log; 108 Eina_Strbuf *exe_log;
110 Eina_Stringshare *date; 109 Eina_Stringshare *date;
@@ -152,11 +151,19 @@ typedef struct
152 Eo *font_list; 151 Eo *font_list;
153} _Text_Set_Data; 152} _Text_Set_Data;
154 153
154typedef struct
155{
156 const char *full_path;
157 Eo *gl_item;
158 Ea_DB *db;
159} _DB_Data;
160
155static Eina_List *_apps = NULL; 161static Eina_List *_apps = NULL;
156static Eo *_log_win = NULL; 162static Eo *_log_win = NULL;
157 163
158static Eo *_mls_gl = NULL, *_units_gl = NULL, *_test_gl = NULL, *_validated_gl = NULL; 164static Eo *_mls_gl = NULL, *_units_gl = NULL, *_test_gl = NULL, *_validated_gl = NULL, *_dbs_gl = NULL;
159static Elm_Genlist_Item_Class *_mls_gl_itc = NULL, *_units_gl_itc = NULL, *_test_gl_itc = NULL; 165static Elm_Genlist_Item_Class *_mls_gl_itc = NULL, *_units_gl_itc = NULL, *_test_gl_itc = NULL, *_dbs_gl_itc = NULL;
166
160static Elm_Genlist_Item_Class *_unit_grp_itc = NULL, *_unit_scn_itc = NULL, *_unit_img_itc = NULL; 167static Elm_Genlist_Item_Class *_unit_grp_itc = NULL, *_unit_scn_itc = NULL, *_unit_img_itc = NULL;
161static Elm_Gengrid_Item_Class *_apps_grid_itc = NULL; 168static Elm_Gengrid_Item_Class *_apps_grid_itc = NULL;
162 169
@@ -200,6 +207,7 @@ static Eo *_scn_gl = NULL;
200static _App_Data *_current_ad = NULL; 207static _App_Data *_current_ad = NULL;
201static Eina_List *_scn_btn_list = NULL; 208static Eina_List *_scn_btn_list = NULL;
202static Eina_Bool _b_only_success; 209static Eina_Bool _b_only_success;
210static Eina_Hash *_dbs_hash = NULL;
203 211
204// Function declaration ----- 212// Function declaration -----
205static Eo* _content_tab_add(Eo *parent, char *style, int height, Eina_Bool is_horiz); 213static Eo* _content_tab_add(Eo *parent, char *style, int height, Eina_Bool is_horiz);
@@ -213,9 +221,56 @@ static Eo *_panel_sub_title_fs_create(Eo *parent, char *title, Evas_Smart_Cb btn
213static void _scn_gen_btn_disabled_set(Eina_Bool disable); 221static void _scn_gen_btn_disabled_set(Eina_Bool disable);
214 222
215static Eo *_spacer_add(Eo *parent, int height); 223static Eo *_spacer_add(Eo *parent, int height);
216static void _app_gen(Eina_Bool one_app); 224static void _app_gen(Eina_Bool one_app, Ea_DB *db);
217static void _app_discard(void *data, Evas_Object *menu EINA_UNUSED, void *item EINA_UNUSED); 225static void _app_discard(void *data, Evas_Object *menu EINA_UNUSED, void *item EINA_UNUSED);
218// Function declaration ----- 226static Eo * _content_tab_icon_add(Eo *parent, _File_Type type);
227
228static Ea_DB *_current_db = NULL;
229
230static Eina_Bool
231_gui_db_is_ready()
232{
233 return !!_current_db;
234}
235
236static Ea_DB*
237_gui_db_activated_get()
238{
239 return _current_db;
240}
241
242static Ea_DB*
243_gui_db_deactivate()
244{
245 Ea_DB *old = _current_db;
246 _current_db = NULL;
247 return old;
248}
249
250static Ea_DB*
251_gui_db_activate(Ea_DB* db)
252{
253 Ea_DB *old = _gui_db_deactivate();
254 _current_db = db;
255
256 elm_genlist_realized_items_update(_dbs_gl);
257 return old;
258}
259
260static void
261_gui_db_generate(Ea_DB *db, Eina_List *flist)
262{
263 Eina_List *itr;
264 const char *fname;
265 Eina_List *files = files_list_get(flist, ".ea");
266
267 EINA_LIST_FOREACH(files, itr, fname)
268 {
269 if (!ecore_file_is_dir(fname))
270 db_ml_add(db, fname);
271 printf("%s\n", fname);
272 }
273}
219 274
220static Eo * 275static Eo *
221_box_create(Eo *parent, Eina_Bool horiz, Eo **wref) 276_box_create(Eo *parent, Eina_Bool horiz, Eo **wref)
@@ -472,20 +527,6 @@ _fs_win_create(Eo *parent, const char *title, Eina_Bool is_save, Evas_Smart_Cb d
472 return win; 527 return win;
473} 528}
474 529
475static void
476_db_all_gen()
477{
478 if (_db) return;
479 Eina_List *files = files_list_get(_config->mls_paths, ".ea");
480 const char *fname;
481 _db = db_new();
482 EINA_LIST_FREE(files, fname)
483 {
484 if (!ecore_file_is_dir(fname))
485 db_ml_add(_db, fname);
486 }
487}
488
489static _App_Data * 530static _App_Data *
490_app_find_by_pid(int pid) 531_app_find_by_pid(int pid)
491{ 532{
@@ -575,6 +616,64 @@ _del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
575 efl_del(data); 616 efl_del(data);
576} 617}
577 618
619static Evas_Object *
620_dbs_gl_content_get(void *data, Evas_Object *obj, const char *part)
621{
622 if (!strcmp(part, "elm.swallow.end"))
623 {
624 _DB_Data *dd = (_DB_Data*)data;
625 if (dd->db && dd->db == _gui_db_activated_get())
626 return _content_tab_icon_add(obj, SETTING);
627 }
628 return NULL;
629}
630
631static char *
632_dbs_gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
633{
634 _DB_Data *dd = (_DB_Data*)data;
635 return strdup(dd->full_path);
636}
637
638static void
639_dbs_gl_double_clicked_cb(void *data EINA_UNUSED, Evas_Object *gl, void *event_info)
640{
641 Elm_Object_Item *glit = event_info;
642 const char *file;
643
644 file = elm_object_item_text_get(glit);
645 if (!file) return;
646 if (gl == _dbs_gl)
647 {
648 _DB_Data *dd = elm_object_item_data_get(event_info);
649 if (!dd) return;
650 _content_tab_item_init(dd->full_path, DB, glit);
651 }
652}
653
654static void
655_dbs_gl_activate_cb(void *data, Evas_Object *menu EINA_UNUSED, void *item EINA_UNUSED)
656{
657 _DB_Data *dd = data;
658 if(dd) _gui_db_activate(dd->db);
659}
660
661static void
662_dbs_gl_clicked_right_cb(void *data EINA_UNUSED, Evas_Object *gl, void *event_info)
663{
664 int x = 0, y = 0;
665 Eo *win = data, *menu;
666 Elm_Object_Item *glit = event_info;
667 _DB_Data *dd = elm_object_item_data_get(glit);
668
669 elm_genlist_item_selected_set(glit, EINA_TRUE);
670 evas_pointer_canvas_xy_get(evas_object_evas_get(gl), &x, &y);
671 menu = elm_menu_add(win);
672 elm_menu_move(menu, x, y);
673 elm_menu_item_add(menu, NULL, NULL, "Activate", _dbs_gl_activate_cb, dd);
674 efl_gfx_entity_visible_set(menu, EINA_TRUE);
675}
676
578static char * 677static char *
579_gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) 678_gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
580{ 679{
@@ -729,8 +828,8 @@ static void
729_source_dir_add(_File_Type type, const char *dir, const char *fname) 828_source_dir_add(_File_Type type, const char *dir, const char *fname)
730{ 829{
731 char *full_path = NULL; 830 char *full_path = NULL;
732 Eo *gl, *gl_item; 831 Eo *gl = NULL, *gl_item = NULL;
733 Elm_Genlist_Item_Class *itc; 832 Elm_Genlist_Item_Class *itc = NULL;
734 if (fname) 833 if (fname)
735 { 834 {
736 char buffer[1024]; 835 char buffer[1024];
@@ -738,33 +837,46 @@ _source_dir_add(_File_Type type, const char *dir, const char *fname)
738 full_path = strdup(buffer); 837 full_path = strdup(buffer);
739 } 838 }
740 else full_path = strdup(dir); 839 else full_path = strdup(dir);
840
741 switch (type) 841 switch (type)
742 { 842 {
743 case ML: 843 case ML:
744 gl = _mls_gl; 844 gl = _mls_gl;
745 itc = _mls_gl_itc; 845 itc = _mls_gl_itc;
746 _config->mls_paths = eina_list_append(_config->mls_paths, full_path); 846 _config->mls_paths = eina_list_append(_config->mls_paths, full_path);
747 break; 847 break;
748
749 case EXU: 848 case EXU:
750 gl = _units_gl; 849 gl = _units_gl;
751 itc = _units_gl_itc; 850 itc = _units_gl_itc;
752 _config->units_paths = eina_list_append(_config->units_paths, full_path); 851 _config->units_paths = eina_list_append(_config->units_paths, full_path);
753 break; 852 break;
754
755 case VALIDATE: 853 case VALIDATE:
756 gl = _validated_gl; 854 gl = _validated_gl;
757 itc = _units_gl_itc; 855 itc = _units_gl_itc;
758 _config->validated_paths = eina_list_append(_config->validated_paths, full_path); 856 _config->validated_paths = eina_list_append(_config->validated_paths, full_path);
759 break; 857 break;
858 case DB:
859 if (ecore_file_is_dir(full_path)) return;
860 gl = _dbs_gl;
861 itc = _dbs_gl_itc;
862 _config->dbs_paths = eina_list_append(_config->dbs_paths, full_path);
863 break;
760 default: 864 default:
761 break; 865 return;
762 } 866 }
763 867
764 gl_item = elm_genlist_item_append(gl, itc, eina_stringshare_add(full_path), NULL, 868 gl_item = elm_genlist_item_append(gl, itc, eina_stringshare_add(full_path), NULL,
765 ecore_file_is_dir(full_path) ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE, 869 ecore_file_is_dir(full_path) ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
766 NULL, NULL); 870 NULL, NULL);
767 efl_key_data_set(gl_item, "full_path", eina_stringshare_add(full_path)); 871 efl_key_data_set(gl_item, "full_path", eina_stringshare_add(full_path));
872
873 if (type == DB)
874 {
875 _DB_Data *dd = calloc(1, sizeof(_DB_Data));
876 dd->full_path = eina_stringshare_add(full_path);
877 dd->gl_item = gl_item;
878 }
879
768 config_save(); 880 config_save();
769} 881}
770 882
@@ -836,15 +948,6 @@ _fs_source_open_cb(void *data EINA_UNUSED, Evas_Object *fs, void *info)
836} 948}
837 949
838static void 950static void
839_fs_open(void *data, Evas_Object *menu EINA_UNUSED, void *item)
840{
841 Eina_Bool is_ml = (item == _ml_menu_item);
842 Eo *fs_win = _fs_win_create(data, is_ml?"Import MLs":"Import Exactness units",
843 EINA_FALSE, _fs_source_open_cb, NULL);
844 efl_key_data_set(fs_win, "is_ml", (void *)(intptr_t)is_ml);
845}
846
847static void
848_btn_ml_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 951_btn_ml_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
849{ 952{
850 Eo *fs_win = _fs_win_create(data, "Import MLs", 953 Eo *fs_win = _fs_win_create(data, "Import MLs",
@@ -861,6 +964,14 @@ _btn_exu_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
861} 964}
862 965
863static void 966static void
967_btn_db_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
968{
969 Eo *fs_win = _fs_win_create(data, "Import Exactness units",
970 EINA_FALSE, _fs_source_open_cb, NULL);
971 efl_key_data_set(fs_win, "type", (void *)DB);
972}
973
974static void
864_btn_validated_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 975_btn_validated_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
865{ 976{
866 Eo *fs_win = _fs_win_create(data, "Import Exactness units", 977 Eo *fs_win = _fs_win_create(data, "Import Exactness units",
@@ -1038,6 +1149,33 @@ _menu_add_to_unit_test_cb(void *data, Evas_Object *obj, void *event_info)
1038 _add_to_unit_test_btn_cb(data, obj, event_info); 1149 _add_to_unit_test_btn_cb(data, obj, event_info);
1039} 1150}
1040 1151
1152
1153static void
1154_generate_database_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1155{
1156 Elm_Object_Item *glit = data;
1157 const char *full_path = efl_key_data_get(glit, "full_path");
1158 if (!full_path || !ecore_file_is_dir(full_path)) return;
1159
1160 _DB_Data *dd = eina_hash_find(_dbs_hash, eina_stringshare_add(full_path));
1161 if (dd) return;
1162
1163 dd = calloc(1, sizeof(_DB_Data));
1164 dd->db = db_new();
1165 dd->full_path = eina_stringshare_add(full_path);
1166 dd->gl_item = elm_genlist_item_append(_dbs_gl, _dbs_gl_itc, dd, NULL,
1167 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1168 efl_key_data_set(dd->gl_item, "full_path", eina_stringshare_add(full_path));
1169
1170 eina_hash_set(_dbs_hash, eina_stringshare_add(full_path), dd);
1171
1172 Eina_List *flist = eina_list_append(NULL, full_path);
1173 _gui_db_generate(dd->db, flist);
1174 _gui_db_activate(dd->db);
1175
1176 _content_tab_item_init(full_path, DB, NULL);
1177}
1178
1041static void 1179static void
1042_gl_clicked_right_cb(void *data, Evas_Object *gl, void *event_info) 1180_gl_clicked_right_cb(void *data, Evas_Object *gl, void *event_info)
1043{ 1181{
@@ -1055,7 +1193,10 @@ _gl_clicked_right_cb(void *data, Evas_Object *gl, void *event_info)
1055 { 1193 {
1056 elm_menu_item_add(menu, NULL, NULL, "Generate a scenario", _ml_to_scn_gen_open_cb, win); 1194 elm_menu_item_add(menu, NULL, NULL, "Generate a scenario", _ml_to_scn_gen_open_cb, win);
1057 if (ecore_file_is_dir(efl_key_data_get(glit, "full_path"))) 1195 if (ecore_file_is_dir(efl_key_data_get(glit, "full_path")))
1058 elm_menu_item_add(menu, NULL, NULL, "Remove directory path", _remove_directory_path_open_cb, glit); 1196 {
1197 elm_menu_item_add(menu, NULL, NULL, "Generate a database", _generate_database_cb, glit);
1198 elm_menu_item_add(menu, NULL, NULL, "Remove directory path", _remove_directory_path_open_cb, glit);
1199 }
1059 } 1200 }
1060 else if (gl == _validated_gl) 1201 else if (gl == _validated_gl)
1061 { 1202 {
@@ -1072,33 +1213,6 @@ _gl_clicked_right_cb(void *data, Evas_Object *gl, void *event_info)
1072} 1213}
1073 1214
1074static void 1215static void
1075_db_gen(void)
1076{
1077 _db_all_gen();
1078 Eina_Strbuf *sbuf = db_get_as_string(_db);
1079
1080 if (sbuf)
1081 {
1082 Eo *o = _label_create(_content_scroller, "", NULL);
1083 efl_content_set(_content_scroller, o);
1084
1085 eina_strbuf_prepend_printf(sbuf, "<font='%s',%s font_size=%d align=left>", _config->font_name, _config->font_name, _config->font_size);
1086 eina_strbuf_replace_all(sbuf, "\n", "<br/>");
1087 eina_strbuf_replace_all(sbuf, "&", "&amp;");
1088
1089 elm_object_text_set(o, eina_strbuf_string_get(sbuf));
1090 eina_strbuf_free(sbuf);
1091 }
1092}
1093
1094static void
1095_db_gen_cb(void *data EINA_UNUSED, Evas_Object *menu EINA_UNUSED, void *item EINA_UNUSED)
1096{
1097 _db_gen();
1098 _content_tab_item_init("DATABASE", DB, NULL);
1099}
1100
1101static void
1102_dialog_cancel(void *data, const Efl_Event *ev EINA_UNUSED) 1216_dialog_cancel(void *data, const Efl_Event *ev EINA_UNUSED)
1103{ 1217{
1104 Eo *win = data; 1218 Eo *win = data;
@@ -1151,7 +1265,7 @@ _async_app_ready(void *data)
1151 if (_b_only_success && (ad->error && !ad->is_deleted)) 1265 if (_b_only_success && (ad->error && !ad->is_deleted))
1152 { 1266 {
1153 _app_discard(data, NULL, NULL); 1267 _app_discard(data, NULL, NULL);
1154 _app_gen(EINA_TRUE); 1268 _app_gen(EINA_TRUE, ad->db);
1155 } 1269 }
1156 _apps_building_cur_nb--; 1270 _apps_building_cur_nb--;
1157 _apps_building_consume(); 1271 _apps_building_consume();
@@ -2125,14 +2239,14 @@ _thread_ml_gen(void *data EINA_UNUSED, Eina_Thread t EINA_UNUSED)
2125 eina_spinlock_release(&_thread_apps_lock); 2239 eina_spinlock_release(&_thread_apps_lock);
2126 if (!ad) continue; 2240 if (!ad) continue;
2127 sprintf(buf, "%s.ml", ad->basename); 2241 sprintf(buf, "%s.ml", ad->basename);
2128 if (!db_ml_gen(_db, buf)) ad->error = EINA_TRUE; 2242 if (!db_ml_gen(ad->db, buf)) ad->error = EINA_TRUE;
2129 ecore_main_loop_thread_safe_call_async(_thread_ml_generated, ad); 2243 ecore_main_loop_thread_safe_call_async(_thread_ml_generated, ad);
2130 } 2244 }
2131 return NULL; 2245 return NULL;
2132} 2246}
2133 2247
2134static void 2248static void
2135_app_gen(Eina_Bool one_app) 2249_app_gen(Eina_Bool one_app, Ea_DB *db)
2136{ 2250{
2137 char buf[256]; 2251 char buf[256];
2138 static int last_year = 0, last_mon, last_mday, last_hour, last_min; 2252 static int last_year = 0, last_mon, last_mday, last_hour, last_min;
@@ -2158,7 +2272,6 @@ _app_gen(Eina_Bool one_app)
2158 last_mon = t->tm_mon; 2272 last_mon = t->tm_mon;
2159 last_hour = t->tm_hour; 2273 last_hour = t->tm_hour;
2160 last_min = t->tm_min; 2274 last_min = t->tm_min;
2161 _db_all_gen();
2162 while (nb > 0 && _version < 999) 2275 while (nb > 0 && _version < 999)
2163 { 2276 {
2164 _App_Data *ad = calloc(1, sizeof(*ad)); 2277 _App_Data *ad = calloc(1, sizeof(*ad));
@@ -2169,6 +2282,7 @@ _app_gen(Eina_Bool one_app)
2169 ad->date = eina_stringshare_add(buf); 2282 ad->date = eina_stringshare_add(buf);
2170 ad->status = ML_GEN; 2283 ad->status = ML_GEN;
2171 ad->item = elm_gengrid_item_append(_apps_grid, _apps_grid_itc, ad, _app_sel_cb, ad); 2284 ad->item = elm_gengrid_item_append(_apps_grid, _apps_grid_itc, ad, _app_sel_cb, ad);
2285 ad->db = db;
2172 sprintf(buf, "/tmp/eagen_%s_%.3d", ad->date, ad->version); 2286 sprintf(buf, "/tmp/eagen_%s_%.3d", ad->date, ad->version);
2173 ad->basename = eina_stringshare_add(buf); 2287 ad->basename = eina_stringshare_add(buf);
2174 _apps = eina_list_append(_apps, ad); 2288 _apps = eina_list_append(_apps, ad);
@@ -2211,13 +2325,15 @@ _app_panel_init(Eina_Bool open)
2211static void 2325static void
2212_app_gen_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED) 2326_app_gen_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
2213{ 2327{
2214 _app_gen(EINA_FALSE); 2328 if (!_gui_db_is_ready()) return;
2329 _app_gen(EINA_FALSE, _gui_db_activated_get());
2215} 2330}
2216 2331
2217static void 2332static void
2218_panel_app_gen_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED) 2333_panel_app_gen_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
2219{ 2334{
2220 _app_gen(EINA_FALSE); 2335 if (!_gui_db_is_ready()) return;
2336 _app_gen(EINA_FALSE, _gui_db_activated_get());
2221 2337
2222 Eina_Bool chk = elm_check_state_get(_btn_app); 2338 Eina_Bool chk = elm_check_state_get(_btn_app);
2223 if (!chk) 2339 if (!chk)
@@ -2908,6 +3024,41 @@ _bg_create(Eo *parent)
2908 return layout; 3024 return layout;
2909} 3025}
2910 3026
3027static Eo *
3028_db_controller_create(Eo *parent, Ea_DB *db)
3029{
3030 Eo *layout = NULL;
3031
3032 layout = efl_add(EFL_UI_LAYOUT_CLASS, parent,
3033 efl_file_set(efl_added, DATA_INSTALL_DIR"/themes/ea_gen.edj", "db_ctrl_layout"),
3034 efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
3035 efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND));
3036
3037 Eina_Strbuf *sbuf = db_get_as_string(db);
3038
3039 if (sbuf)
3040 {
3041 char pre_buf[128] = {0};
3042 Eo *o1, *s1;
3043
3044 s1 = _scroller_add(layout, NULL);
3045 efl_content_set(efl_part(layout, "swallow_left"), s1);
3046
3047 o1 = _label_create(layout, "", NULL);
3048 efl_content_set(s1, o1);
3049
3050 snprintf(pre_buf, sizeof(pre_buf), "<font='%s',%s font_size=%d align=left>", _config->font_name, _config->font_name, _config->font_size);
3051 eina_strbuf_prepend(sbuf, pre_buf);
3052 eina_strbuf_replace_all(sbuf, "\n", "<br/>");
3053 eina_strbuf_replace_all(sbuf, "&", "&amp;");
3054 elm_object_text_set(o1, eina_strbuf_string_get(sbuf));
3055
3056 eina_strbuf_free(sbuf);
3057 }
3058
3059 return layout;
3060}
3061
2911static Eina_Bool 3062static Eina_Bool
2912_app_find_and_select(_App_Data *ad) 3063_app_find_and_select(_App_Data *ad)
2913{ 3064{
@@ -2972,9 +3123,15 @@ _content_tab_content_display(Elm_Object_Item *it)
2972 case DB: 3123 case DB:
2973 if (!td->is_preview) 3124 if (!td->is_preview)
2974 { 3125 {
2975 _scn_gl_init(); 3126 _scn_gen_btn_disabled_set(EINA_TRUE);
2976 _db_gen(); 3127 if (elm_genlist_items_count(_scn_gl) != 0)
2977 _content_tab_item_init("DATABASE", DB, NULL); 3128 elm_genlist_clear(_scn_gl);
3129 elm_gengrid_item_selected_set(elm_gengrid_selected_item_get(_apps_grid), EINA_FALSE);
3130
3131 _DB_Data *dd = eina_hash_find(_dbs_hash, eina_stringshare_add(td->file));
3132 if (!dd) return;
3133
3134 efl_content_set(_content_scroller, _db_controller_create(_content_scroller, dd->db));
2978 } 3135 }
2979 break; 3136 break;
2980 3137
@@ -4111,16 +4268,6 @@ _db_panel_create(Eo *parent)
4111 box = efl_add(EFL_UI_BOX_CLASS, parent, 4268 box = efl_add(EFL_UI_BOX_CLASS, parent,
4112 efl_pack_align_set(efl_added, -1, 0)); 4269 efl_pack_align_set(efl_added, -1, 0));
4113 4270
4114 efl_pack_end(box, _panel_sub_title_create(box, "Database"));
4115
4116 btn = efl_add(EFL_UI_BUTTON_CLASS, box,
4117 efl_text_set(efl_added, "Generate DB"),
4118 efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0),
4119 efl_pack_end(box, efl_added));
4120 evas_object_smart_callback_add(btn, "clicked", _db_gen_cb, NULL);
4121
4122 efl_pack_end(box, _spacer_add(box, 100));
4123
4124 _panel_sub_title_create(box, "Generator"); 4271 _panel_sub_title_create(box, "Generator");
4125 4272
4126 btn = efl_add(EFL_UI_BUTTON_CLASS, box, 4273 btn = efl_add(EFL_UI_BUTTON_CLASS, box,
@@ -4267,6 +4414,8 @@ gui_create(void)
4267 ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_error_cb, NULL); 4414 ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_error_cb, NULL);
4268 ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _exe_end_cb, NULL); 4415 ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _exe_end_cb, NULL);
4269 4416
4417 _dbs_hash = eina_hash_string_superfast_new(NULL);
4418
4270 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), 4419 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
4271 efl_ui_win_name_set(efl_added, "EaGen"), 4420 efl_ui_win_name_set(efl_added, "EaGen"),
4272 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC), 4421 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
@@ -4275,10 +4424,9 @@ gui_create(void)
4275 efl_ui_win_maximized_set(win, EINA_TRUE); 4424 efl_ui_win_maximized_set(win, EINA_TRUE);
4276 4425
4277 Eo *menu = elm_win_main_menu_get(win); 4426 Eo *menu = elm_win_main_menu_get(win);
4278 _ml_menu_item = elm_menu_item_add(menu, NULL, NULL, "Import Meta-Files", _fs_open, win); 4427 _ml_menu_item = elm_menu_item_add(menu, NULL, NULL, "Import Meta-Files", _btn_ml_open, win);
4279 _unit_menu_item = elm_menu_item_add(menu, NULL, NULL, "Import Exactness units", _fs_open, win); 4428 _unit_menu_item = elm_menu_item_add(menu, NULL, NULL, "Import Exactness units", _btn_exu_open, win);
4280 elm_menu_item_add(menu, NULL, NULL, "Generate a scenario", _ml_to_scn_gen_open_cb, win); 4429 elm_menu_item_add(menu, NULL, NULL, "Generate a scenario", _ml_to_scn_gen_open_cb, win);
4281 elm_menu_item_add(menu, NULL, NULL, "Display DB", _db_gen_cb, NULL);
4282 elm_menu_item_add(menu, NULL, NULL, "Generate program", _prg_gen_cb, NULL); 4430 elm_menu_item_add(menu, NULL, NULL, "Generate program", _prg_gen_cb, NULL);
4283 4431
4284 h_box = efl_add(EFL_UI_BOX_CLASS, win, 4432 h_box = efl_add(EFL_UI_BOX_CLASS, win,
@@ -4405,6 +4553,30 @@ gui_create(void)
4405 efl_key_data_set(gl_item, "full_path", eina_stringshare_add(path)); 4553 efl_key_data_set(gl_item, "full_path", eina_stringshare_add(path));
4406 } 4554 }
4407 4555
4556 _panel_sub_title_fs_create(sub_box, "Databases", _btn_db_open, win);
4557 o = _scroller_add(p2, NULL);
4558 efl_pack_end(sub_box, o);
4559
4560 _genlist_create(o, &_dbs_gl);
4561 efl_content_set(o, _dbs_gl);
4562
4563 _dbs_gl_itc = elm_genlist_item_class_new();
4564 _dbs_gl_itc->item_style = "default";
4565 _dbs_gl_itc->func.text_get = _dbs_gl_text_get;
4566 _dbs_gl_itc->func.content_get = _dbs_gl_content_get;
4567
4568 evas_object_smart_callback_add(_dbs_gl, "clicked,double", _dbs_gl_double_clicked_cb, NULL);
4569 evas_object_smart_callback_add(_dbs_gl, "clicked,right", _dbs_gl_clicked_right_cb, win);
4570
4571 EINA_LIST_FOREACH(_config->dbs_paths, itr, path)
4572 {
4573 _DB_Data *dd = calloc(1, sizeof(_DB_Data));
4574 dd->full_path = eina_stringshare_add(path);
4575 dd->gl_item = elm_genlist_item_append(_dbs_gl, _dbs_gl_itc, dd, NULL,
4576 ecore_file_is_dir(path) ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
4577 NULL, NULL);
4578 }
4579
4408 sub_box = efl_add(EFL_UI_BOX_CLASS, p2, 4580 sub_box = efl_add(EFL_UI_BOX_CLASS, p2,
4409 elm_object_part_content_set(p2, "bottom", efl_added)); 4581 elm_object_part_content_set(p2, "bottom", efl_added));
4410 4582
@@ -4417,7 +4589,7 @@ gui_create(void)
4417 _genlist_create(o, &_units_gl); 4589 _genlist_create(o, &_units_gl);
4418 efl_content_set(o, _units_gl); 4590 efl_content_set(o, _units_gl);
4419 4591
4420 elm_panes_content_right_size_set(p2, 0.5); 4592 elm_panes_content_right_size_set(p2, M_PI/10.0);
4421 4593
4422 _units_gl_itc = elm_genlist_item_class_new(); 4594 _units_gl_itc = elm_genlist_item_class_new();
4423 _units_gl_itc->item_style = "default"; 4595 _units_gl_itc->item_style = "default";
diff --git a/src/bin/main.c b/src/bin/main.c
index abddbc3..f748d4d 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -48,6 +48,7 @@ _config_eet_load()
48 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "mls_paths", mls_paths); 48 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "mls_paths", mls_paths);
49 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "units_paths", units_paths); 49 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "units_paths", units_paths);
50 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "validated_paths", validated_paths); 50 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "validated_paths", validated_paths);
51 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_config_edd, Config, "dbs_paths", dbs_paths);
51 52
52 EET_DATA_DESCRIPTOR_ADD_BASIC(_config_edd, Config, "efl_install_dir", efl_install_dir, EET_T_STRING); 53 EET_DATA_DESCRIPTOR_ADD_BASIC(_config_edd, Config, "efl_install_dir", efl_install_dir, EET_T_STRING);
53 EET_DATA_DESCRIPTOR_ADD_BASIC(_config_edd, Config, "efl_repo_dir", efl_repo_dir, EET_T_STRING); 54 EET_DATA_DESCRIPTOR_ADD_BASIC(_config_edd, Config, "efl_repo_dir", efl_repo_dir, EET_T_STRING);