summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-25 10:59:46 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-25 16:35:43 +0300
commit44157d48e14a0cec623d5e237265ab87e97db8c4 (patch)
tree7a22ba72780db606a8247c447b084a68ad795d74
parenta7bfc553d9777748372fbe2813575b322bcee0f3 (diff)
refactoring Generator interface
- renaming get_gui() -> project_name_gui_get
-rw-r--r--src/bin/egui_gui/CMakeLists.txt2
-rw-r--r--src/bin/egui_gui/editor.c1
-rw-r--r--src/bin/egui_gui/egui_layout_c.json19
-rw-r--r--src/bin/egui_gui/egui_layout_h.json2
-rw-r--r--src/bin/egui_gui/egui_logic.c6
-rw-r--r--src/bin/egui_gui/egui_logic_private.h2
-rw-r--r--src/bin/egui_gui/settings_view.c2
-rw-r--r--src/bin/main.c22
-rw-r--r--src/lib/generator.c92
-rw-r--r--src/lib/generator.h2
-rw-r--r--src/lib/generator_interface.eo9
-rw-r--r--src/lib/gui_widget.c14
-rw-r--r--src/lib/gui_widget.h6
13 files changed, 126 insertions, 53 deletions
diff --git a/src/bin/egui_gui/CMakeLists.txt b/src/bin/egui_gui/CMakeLists.txt
index 18a5934..f985b99 100644
--- a/src/bin/egui_gui/CMakeLists.txt
+++ b/src/bin/egui_gui/CMakeLists.txt
@@ -119,7 +119,7 @@ add_custom_command (
119 OUTPUT tmp/egui_layout.c tmp/egui_layout.h 119 OUTPUT tmp/egui_layout.c tmp/egui_layout.h
120 COMMENT "Generating gui layout from JSON" 120 COMMENT "Generating gui layout from JSON"
121 COMMAND ${CMAKE_COMMAND} -E make_directory tmp 121 COMMAND ${CMAKE_COMMAND} -E make_directory tmp
122 COMMAND ${EGUI_BINARY_BLD}/egui_cmd -f ${CMAKE_CURRENT_SOURCE_DIR}/egui_layout_c.json -g -o egui_layout -p ./tmp 122 COMMAND ${EGUI_BINARY_BLD}/egui_cmd -f ${CMAKE_CURRENT_SOURCE_DIR}/egui_layout_c.json -e c -o egui_layout -p ./tmp
123 ) 123 )
124 124
125target_link_libraries (${TARGET2} 125target_link_libraries (${TARGET2}
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index 4a35527..fd7100e 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -1965,6 +1965,7 @@ _project_new(char *filename)
1965 objtree_context_set(ctx); 1965 objtree_context_set(ctx);
1966 seqview_fill(ctx); 1966 seqview_fill(ctx);
1967 1967
1968 gui_context_project_name_set(ctx, "new_project");
1968 /* Assign new editor session tocontext */ 1969 /* Assign new editor session tocontext */
1969 gui_context_editor_session_set(_active_context_get(), session_new()); 1970 gui_context_editor_session_set(_active_context_get(), session_new());
1970 1971
diff --git a/src/bin/egui_gui/egui_layout_c.json b/src/bin/egui_gui/egui_layout_c.json
index f9d6968..67e999b 100644
--- a/src/bin/egui_gui/egui_layout_c.json
+++ b/src/bin/egui_gui/egui_layout_c.json
@@ -44,6 +44,23 @@ static Eo *main_win;
44 } 44 }
45 } 45 }
46@!egui */ 46@!egui */
47
48/* @egui
49{
50 "Settings":
51 {
52 "Desc":
53 {
54 "type":"settings"
55 },
56 "Settings":
57 {
58 "project":"egui_layout"
59 }
60 }
61 }
62@!egui */
63
47extern Eina_Bool 64extern Eina_Bool
48_itemview_item_add_but_clicked_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 65_itemview_item_add_but_clicked_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
49extern Eina_Bool 66extern Eina_Bool
@@ -3889,7 +3906,7 @@ _sequence_BigBang_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_
3889 return EO_CALLBACK_CONTINUE; 3906 return EO_CALLBACK_CONTINUE;
3890} 3907}
3891 3908
3892GUI* get_gui() 3909GUI* egui_layout_gui_get()
3893{ 3910{
3894 static Eina_Bool initialized = EINA_FALSE; 3911 static Eina_Bool initialized = EINA_FALSE;
3895 if (!initialized) 3912 if (!initialized)
diff --git a/src/bin/egui_gui/egui_layout_h.json b/src/bin/egui_gui/egui_layout_h.json
index c621b21..8f8ace0 100644
--- a/src/bin/egui_gui/egui_layout_h.json
+++ b/src/bin/egui_gui/egui_layout_h.json
@@ -82,5 +82,5 @@ _sequence_rm_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *d
82Eina_Bool 82Eina_Bool
83_sequence_settings_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 83_sequence_settings_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
84 84
85GUI *get_gui(); 85GUI *egui_layout_gui_get();
86#endif 86#endif
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index cd0c72b..e2ec657 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -172,9 +172,9 @@ _on_fs_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
172 172
173 if (can_save) 173 if (can_save)
174 { 174 {
175 gui_context_project_name_set(_active_context_get(), filename); 175 gui_context_project_filename_set(_active_context_get(), filename);
176 gui_context_project_path_set(_active_context_get(), (const char *) parent_dir); 176 gui_context_project_path_set(_active_context_get(), (const char *) parent_dir);
177 generator_ctx_source_generate(_active_context_get(), parent_dir, GENERATION_C, GENERATE_JSON_CODE); 177 generator_ctx_source_generate(_active_context_get(), GENERATION_C, GENERATE_JSON_CODE);
178 _canvas_name_update(_active_context_get()); 178 _canvas_name_update(_active_context_get());
179 } 179 }
180 free(parent_dir); 180 free(parent_dir);
@@ -286,7 +286,7 @@ _project_save(Gui_Context *ctx)
286 _fs_save_as_open(); 286 _fs_save_as_open();
287 return; 287 return;
288 } 288 }
289 generator_ctx_source_generate(ctx, dir, GENERATION_C, GENERATE_JSON_CODE); 289 generator_ctx_source_generate(ctx, GENERATION_C, GENERATE_JSON_CODE);
290} 290}
291 291
292static void 292static void
diff --git a/src/bin/egui_gui/egui_logic_private.h b/src/bin/egui_gui/egui_logic_private.h
index efb2a44..c1bd4e7 100644
--- a/src/bin/egui_gui/egui_logic_private.h
+++ b/src/bin/egui_gui/egui_logic_private.h
@@ -5,6 +5,8 @@
5#include "egui_layout.h" 5#include "egui_layout.h"
6#include "seqview.h" 6#include "seqview.h"
7 7
8#define get_gui egui_layout_gui_get
9
8typedef struct 10typedef struct
9{ 11{
10 Eina_Bool (*_layout_clear)(const Gui_Context *ctx, Eina_Bool delete_widgets); 12 Eina_Bool (*_layout_clear)(const Gui_Context *ctx, Eina_Bool delete_widgets);
diff --git a/src/bin/egui_gui/settings_view.c b/src/bin/egui_gui/settings_view.c
index 00b0ba7..368fbbf 100644
--- a/src/bin/egui_gui/settings_view.c
+++ b/src/bin/egui_gui/settings_view.c
@@ -54,7 +54,7 @@ Eina_Bool
54_settings_win_show_post_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 54_settings_win_show_post_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
55{ 55{
56 GUI *g = get_gui(); 56 GUI *g = get_gui();
57 eo_do(g->settings_toolbar, elm_obj_toolbar_item_append(NULL, "Project", 57 eo_do(g->settings_toolbar, elm_obj_toolbar_item_append("preferences-system", "Project",
58 _settingsview_toolbar_clicked, (void *) (intptr_t) SETTINGSVIEW_MAIN)); 58 _settingsview_toolbar_clicked, (void *) (intptr_t) SETTINGSVIEW_MAIN));
59 return EO_CALLBACK_CONTINUE; 59 return EO_CALLBACK_CONTINUE;
60} 60}
diff --git a/src/bin/main.c b/src/bin/main.c
index eebb16b..3279c3d 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -11,7 +11,7 @@
11#endif 11#endif
12 12
13static Eina_Bool 13static Eina_Bool
14_generate(const char *filename, const char* path, const char *new_project_name, Generator_Export_Format format, Generator_Export_Mode mode) 14_generate(const char *filename, const char* path, const char *new_filename, Generator_Export_Format format, Generator_Export_Mode mode)
15{ 15{
16 Gui_Context *ctx; 16 Gui_Context *ctx;
17 ctx = gui_context_new();; 17 ctx = gui_context_new();;
@@ -28,11 +28,9 @@ _generate(const char *filename, const char* path, const char *new_project_name,
28 } 28 }
29 29
30 /* if new_project_name is no NULL, we want to put new project name. */ 30 /* if new_project_name is no NULL, we want to put new project name. */
31 if (new_project_name) 31 gui_context_project_path_set(ctx, path);
32 { 32 gui_context_project_filename_set(ctx, new_filename);
33 gui_context_project_name_set(ctx, new_project_name); 33 generator_ctx_source_generate(ctx, format, mode);
34 }
35 generator_ctx_source_generate(ctx, path, format, mode);
36 gui_context_del(ctx); 34 gui_context_del(ctx);
37 return EINA_TRUE; 35 return EINA_TRUE;
38} 36}
@@ -104,7 +102,7 @@ _manager_init_check();
104int 102int
105main(int argc, char **argv) 103main(int argc, char **argv)
106{ 104{
107 const char *path = ".", *new_project_name = NULL, *target_name = NULL; 105 const char *path = ".", *new_filename = NULL, *target_name = NULL;
108 char *filename = NULL; 106 char *filename = NULL;
109 const char *mode = NULL; 107 const char *mode = NULL;
110 Generator_Export_Format export_format = GENERATION_C; 108 Generator_Export_Format export_format = GENERATION_C;
@@ -178,7 +176,7 @@ main(int argc, char **argv)
178 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1))) 176 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
179 { 177 {
180 i++; 178 i++;
181 new_project_name = argv[i]; 179 new_filename = argv[i];
182 } 180 }
183 else if (!strcmp(argv[i], "--json")) 181 else if (!strcmp(argv[i], "--json"))
184 { 182 {
@@ -218,7 +216,13 @@ main(int argc, char **argv)
218 } 216 }
219 else 217 else
220 { 218 {
221 _generate(filename, path, new_project_name, export_format, export_mode); 219 if ((!path) || (!new_filename))
220 {
221 printf("missing path or filename\n");
222 _help();
223 return 1;
224 }
225 _generate(filename, path, new_filename, export_format, export_mode);
222 } 226 }
223 } 227 }
224 228
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 50d48ab..b22f27f 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -687,17 +687,18 @@ _settings_to_json(const Gui_Context *ctx)
687 687
688/* Save context into "project" files. */ 688/* Save context into "project" files. */
689static void 689static void
690_ctx_to_file_save(Gui_Context *ctx, const char *path) 690_ctx_to_file_save(Gui_Context *ctx)
691{ 691{
692 const char *project = gui_context_project_name_get(ctx); 692 const char *path = gui_context_project_path_get(ctx);
693 char *filename_c = (char *) calloc(strlen(path) + strlen(project) + 4, 1); 693 const char *filename = gui_context_project_filename_get(ctx);
694 char *filename_h = (char *) calloc(strlen(path) + strlen(project) + 4, 1); 694 char *filename_c = (char *) calloc(strlen(path) + strlen(filename) + 4, 1);
695 char *filename_h = (char *) calloc(strlen(path) + strlen(filename) + 4, 1);
695 FILE *fp_c, *fp_h; 696 FILE *fp_c, *fp_h;
696 Variable_Data *vd; 697 Variable_Data *vd;
697 Eina_List *itr; 698 Eina_List *itr;
698 699
699 sprintf(filename_c, "%s/%s%s", path, project, ".c"); 700 sprintf(filename_c, "%s/%s%s", path, filename, ".c");
700 sprintf(filename_h, "%s/%s%s", path, project, ".h"); 701 sprintf(filename_h, "%s/%s%s", path, filename, ".h");
701 fp_c = fopen(filename_c, "w+"); 702 fp_c = fopen(filename_c, "w+");
702 fp_h = fopen(filename_h, "w+"); 703 fp_h = fopen(filename_h, "w+");
703 704
@@ -722,7 +723,7 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
722 723
723 if (_export_mode & GENERATE_CODE) 724 if (_export_mode & GENERATE_CODE)
724 { 725 {
725 eo_do(C_generator, generator_interface_source_preamble_generate(project, gl_gen_ctx.buf)); 726 eo_do(C_generator, generator_interface_source_preamble_generate(ctx, gl_gen_ctx.buf));
726 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__"); 727 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__");
727 } 728 }
728 729
@@ -779,7 +780,7 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
779 780
780 if (_export_mode & GENERATE_CODE) 781 if (_export_mode & GENERATE_CODE)
781 { 782 {
782 eo_do(C_generator, generator_interface_main_function_generate(ctx, project, gl_gen_ctx.buf)); 783 eo_do(C_generator, generator_interface_main_function_generate(ctx, gl_gen_ctx.buf));
783 } 784 }
784 785
785 /* Print all data from buffer into the file. */ 786 /* Print all data from buffer into the file. */
@@ -788,7 +789,7 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
788 /* Generate header file. */ 789 /* Generate header file. */
789 { 790 {
790 eina_strbuf_reset(gl_gen_ctx.buf); 791 eina_strbuf_reset(gl_gen_ctx.buf);
791 eo_do(C_generator, generator_interface_header_preamble_generate(project, gl_gen_ctx.buf)); 792 eo_do(C_generator, generator_interface_header_preamble_generate(ctx, gl_gen_ctx.buf));
792 793
793 eo_do(C_generator, generator_interface_header_public_variables_generate(gl_gen_ctx.public_names, gl_gen_ctx.buf)); 794 eo_do(C_generator, generator_interface_header_public_variables_generate(gl_gen_ctx.public_names, gl_gen_ctx.buf));
794 EINA_LIST_FOREACH(gl_gen_ctx.public_names, itr, vd) 795 EINA_LIST_FOREACH(gl_gen_ctx.public_names, itr, vd)
@@ -798,8 +799,8 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
798 eo_do(C_generator, generator_interface_header_sequence_generate(vd->var_name, gl_gen_ctx.buf)); 799 eo_do(C_generator, generator_interface_header_sequence_generate(vd->var_name, gl_gen_ctx.buf));
799 } 800 }
800 } 801 }
801 eo_do(C_generator, generator_interface_header_main_function_generate(project, gl_gen_ctx.buf)); 802 eo_do(C_generator, generator_interface_header_main_function_generate(ctx, gl_gen_ctx.buf));
802 eo_do(C_generator, generator_interface_header_postscript_generate(project, gl_gen_ctx.buf)); 803 eo_do(C_generator, generator_interface_header_postscript_generate(ctx, gl_gen_ctx.buf));
803 fprintf(fp_h, "%s", eina_strbuf_string_get(gl_gen_ctx.buf)); 804 fprintf(fp_h, "%s", eina_strbuf_string_get(gl_gen_ctx.buf));
804 } 805 }
805 806
@@ -826,7 +827,7 @@ end:
826} 827}
827 828
828void 829void
829generator_ctx_source_generate(Gui_Context *ctx, const char *path, Generator_Export_Format format, Generator_Export_Mode mode) 830generator_ctx_source_generate(Gui_Context *ctx, Generator_Export_Format format, Generator_Export_Mode mode)
830{ 831{
831 if (!gui_context_win_list_get(ctx)) 832 if (!gui_context_win_list_get(ctx))
832 { 833 {
@@ -861,7 +862,7 @@ generator_ctx_source_generate(Gui_Context *ctx, const char *path, Generator_Expo
861 funcs->item_add = _item_add_generate; 862 funcs->item_add = _item_add_generate;
862 863
863 _export_mode = mode; 864 _export_mode = mode;
864 _ctx_to_file_save(ctx, path); 865 _ctx_to_file_save(ctx);
865} 866}
866 867
867 868
@@ -1325,13 +1326,14 @@ _seq_to_json_str_get(Gui_Sequence *seq)
1325} 1326}
1326 1327
1327EOLIAN static Eina_Bool 1328EOLIAN static Eina_Bool
1328_c_generator_generator_interface_source_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project, Eina_Strbuf *buf) 1329_c_generator_generator_interface_source_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1329{ 1330{
1331 const char *filename = gui_context_project_filename_get(ctx);
1330 eina_strbuf_append_printf(buf, 1332 eina_strbuf_append_printf(buf,
1331 "#include <Elementary.h>\n" 1333 "#include <Elementary.h>\n"
1332 "#include \"elm_widget_container.h\"\n" 1334 "#include \"elm_widget_container.h\"\n"
1333 "#include \"elm_interface_scrollable.h\"\n" 1335 "#include \"elm_interface_scrollable.h\"\n"
1334 "#include \"%s.h\"\n\n", project); 1336 "#include \"%s.h\"\n\n", filename);
1335 1337
1336 eina_strbuf_append_printf(buf, 1338 eina_strbuf_append_printf(buf,
1337 "static GUI %s;\n\n", PUB_WIDGETS); 1339 "static GUI %s;\n\n", PUB_WIDGETS);
@@ -1388,22 +1390,42 @@ _c_generator_generator_interface_resource_generate(Eo *obj EINA_UNUSED, void *pd
1388 return EINA_TRUE; 1390 return EINA_TRUE;
1389} 1391}
1390 1392
1393/* Replaces spaces and dashes to underscore,
1394 * and lowercase string*/
1395static char*
1396_project_name_format(char *in_str)
1397{
1398 Eina_Strbuf *buf = eina_strbuf_new();
1399 eina_strbuf_append_printf(buf, "%s", in_str);
1400 eina_strbuf_replace_all(buf, " ", "_");
1401 eina_strbuf_replace_all(buf, "-", "_");
1402 char *ret = strdup((char *) eina_strbuf_string_get(buf));
1403 eina_str_tolower(&ret);
1404 eina_strbuf_free(buf);
1405 return ret;
1406}
1407
1391EOLIAN static Eina_Bool 1408EOLIAN static Eina_Bool
1392_c_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, const char *project EINA_UNUSED, Eina_Strbuf *buf) 1409_c_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1393{ 1410{
1394 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, "BigBang"); 1411 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, "BigBang");
1395 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id); 1412 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id);
1396 const char *func_name = resource_value_get(res); 1413 const char *func_name = resource_value_get(res);
1414
1415 char *project_name = (char *) gui_context_project_name_get(ctx);
1416 char *formatted = _project_name_format(project_name);
1417
1397 /* Add get_gui function . */ 1418 /* Add get_gui function . */
1398 eina_strbuf_append_printf(buf, 1419 eina_strbuf_append_printf(buf,
1399 "GUI* get_gui()\n{\n" 1420 "GUI* %s_gui_get()\n{\n"
1400 " static Eina_Bool initialized = EINA_FALSE;\n" 1421 " static Eina_Bool initialized = EINA_FALSE;\n"
1401 " if (!initialized)\n" 1422 " if (!initialized)\n"
1402 " {\n" 1423 " {\n"
1403 " %s(NULL, NULL, NULL, NULL);\n" 1424 " %s(NULL, NULL, NULL, NULL);\n"
1404 " initialized = EINA_TRUE;\n" 1425 " initialized = EINA_TRUE;\n"
1405 " }\n" 1426 " }\n"
1406 " return &%s;\n}", func_name, PUB_WIDGETS); 1427 " return &%s;\n}", formatted, func_name, PUB_WIDGETS);
1428 free(formatted);
1407 return EINA_TRUE; 1429 return EINA_TRUE;
1408} 1430}
1409 1431
@@ -1631,10 +1653,13 @@ _c_generator_generator_interface_widget_item_add(Eo *obj EINA_UNUSED, void *pd E
1631} 1653}
1632 1654
1633EOLIAN static Eina_Bool 1655EOLIAN static Eina_Bool
1634_c_generator_generator_interface_header_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project EINA_UNUSED, Eina_Strbuf *buf) 1656_c_generator_generator_interface_header_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1635{ 1657{
1636 /* Add get_gui function . */ 1658 /* Add get_gui function . */
1637 eina_strbuf_append_printf(buf, "GUI *get_gui();\n"); 1659 char *project_name = (char *) gui_context_project_name_get(ctx);
1660 char *formatted = _project_name_format(project_name);
1661 eina_strbuf_append_printf(buf, "GUI *%s_gui_get();\n", formatted);
1662 free(formatted);
1638 return EINA_TRUE; 1663 return EINA_TRUE;
1639} 1664}
1640 1665
@@ -1648,11 +1673,13 @@ _c_generator_generator_interface_header_sequence_generate(Eo *obj EINA_UNUSED, v
1648} 1673}
1649 1674
1650EOLIAN static Eina_Bool 1675EOLIAN static Eina_Bool
1651_c_generator_generator_interface_header_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project, Eina_Strbuf *buf) 1676_c_generator_generator_interface_header_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1652{ 1677{
1678 /* FIXME: add concatenation here*/
1679 const char *filename = gui_context_project_filename_get(ctx);
1653 eina_strbuf_append_printf(buf, 1680 eina_strbuf_append_printf(buf,
1654 "#ifndef _%s_h\n" 1681 "#ifndef _%s_h\n"
1655 "#define _%s_h\n", project, project); 1682 "#define _%s_h\n", filename, filename);
1656 eina_strbuf_append_printf(buf, 1683 eina_strbuf_append_printf(buf,
1657 "#include <Eo.h>\n" 1684 "#include <Eo.h>\n"
1658 "#include <Elementary.h>\n\n"); 1685 "#include <Elementary.h>\n\n");
@@ -1661,7 +1688,7 @@ _c_generator_generator_interface_header_preamble_generate(Eo *obj EINA_UNUSED, v
1661} 1688}
1662 1689
1663EOLIAN static Eina_Bool 1690EOLIAN static Eina_Bool
1664_c_generator_generator_interface_header_postscript_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project EINA_UNUSED, Eina_Strbuf *buf) 1691_c_generator_generator_interface_header_postscript_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx EINA_UNUSED, Eina_Strbuf *buf)
1665{ 1692{
1666 eina_strbuf_append_printf(buf, "#endif\n"); 1693 eina_strbuf_append_printf(buf, "#endif\n");
1667 1694
@@ -1696,14 +1723,15 @@ _c_generator_generator_interface_header_public_variables_generate(Eo *obj EINA_U
1696#include "C_generator.eo.c" 1723#include "C_generator.eo.c"
1697 1724
1698EOLIAN static Eina_Bool 1725EOLIAN static Eina_Bool
1699_cxx_generator_generator_interface_source_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project, Eina_Strbuf *buf) 1726_cxx_generator_generator_interface_source_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1700{ 1727{
1728 const char *filename = gui_context_project_filename_get(ctx);
1701 eina_strbuf_append_printf(buf, 1729 eina_strbuf_append_printf(buf,
1702 "#include <Elementary.hh>\n" 1730 "#include <Elementary.hh>\n"
1703 "#include \"elm_widget.hh\"\n" 1731 "#include \"elm_widget.hh\"\n"
1704 "#include \"elm_widget_container.hh\"\n" 1732 "#include \"elm_widget_container.hh\"\n"
1705 "#include \"elm_interface_scrollable.hh\"\n" 1733 "#include \"elm_interface_scrollable.hh\"\n"
1706 "#include \"%s.hh\"\n\n", project); 1734 "#include \"%s.hh\"\n\n", filename);
1707 1735
1708 return EINA_TRUE; 1736 return EINA_TRUE;
1709} 1737}
@@ -1758,11 +1786,12 @@ _cxx_generator_generator_interface_resource_generate(Eo *obj EINA_UNUSED, void *
1758} 1786}
1759 1787
1760EOLIAN static Eina_Bool 1788EOLIAN static Eina_Bool
1761_cxx_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, const char *project, Eina_Strbuf *buf) 1789_cxx_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1762{ 1790{
1763 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, "BigBang"); 1791 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, "BigBang");
1764 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_EO_CALLBACK, dep_id); 1792 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_EO_CALLBACK, dep_id);
1765 const char *func_name = resource_value_get(res); 1793 const char *func_name = resource_value_get(res);
1794 const char *project = gui_context_project_name_get(ctx);
1766 /* Add get_gui function . */ 1795 /* Add get_gui function . */
1767 eina_strbuf_append_printf(buf, 1796 eina_strbuf_append_printf(buf,
1768 "Eina_Bool %s_Gui::Create()\n{\n" 1797 "Eina_Bool %s_Gui::Create()\n{\n"
@@ -1871,7 +1900,7 @@ _cxx_generator_generator_interface_widget_item_add(Eo *obj EINA_UNUSED, void *pd
1871} 1900}
1872 1901
1873EOLIAN static Eina_Bool 1902EOLIAN static Eina_Bool
1874_cxx_generator_generator_interface_header_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project EINA_UNUSED, Eina_Strbuf *buf EINA_UNUSED) 1903_cxx_generator_generator_interface_header_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx EINA_UNUSED, Eina_Strbuf *buf EINA_UNUSED)
1875{ 1904{
1876 eina_strbuf_append_printf(buf, " Create();\n"); 1905 eina_strbuf_append_printf(buf, " Create();\n");
1877 return EINA_TRUE; 1906 return EINA_TRUE;
@@ -1888,21 +1917,22 @@ _cxx_generator_generator_interface_header_sequence_generate(Eo *obj EINA_UNUSED,
1888} 1917}
1889 1918
1890EOLIAN static Eina_Bool 1919EOLIAN static Eina_Bool
1891_cxx_generator_generator_interface_header_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project, Eina_Strbuf *buf) 1920_cxx_generator_generator_interface_header_preamble_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1892{ 1921{
1922 const char *filename = gui_context_project_filename_get(ctx);
1893 eina_strbuf_append_printf(buf, 1923 eina_strbuf_append_printf(buf,
1894 "#ifndef _%s_hh\n" 1924 "#ifndef _%s_hh\n"
1895 "#define _%s_hh\n", project, project); 1925 "#define _%s_hh\n", filename, filename);
1896 eina_strbuf_append_printf(buf, 1926 eina_strbuf_append_printf(buf,
1897 "#include <Eo.hh>\n" 1927 "#include <Eo.hh>\n"
1898 "#include <Elementary.hh>\n\n"); 1928 "#include <Elementary.hh>\n\n");
1899 eina_strbuf_append_printf(buf, "class %s_Gui\n{\n public:\n", project); 1929 eina_strbuf_append_printf(buf, "class %s_Gui\n{\n public:\n", filename);
1900 1930
1901 return EINA_TRUE; 1931 return EINA_TRUE;
1902} 1932}
1903 1933
1904EOLIAN static Eina_Bool 1934EOLIAN static Eina_Bool
1905_cxx_generator_generator_interface_header_postscript_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *project EINA_UNUSED, Eina_Strbuf *buf) 1935_cxx_generator_generator_interface_header_postscript_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx EINA_UNUSED, Eina_Strbuf *buf)
1906{ 1936{
1907 /* end of the class */ 1937 /* end of the class */
1908 eina_strbuf_append_printf(buf, "};\n"); 1938 eina_strbuf_append_printf(buf, "};\n");
diff --git a/src/lib/generator.h b/src/lib/generator.h
index 372fce9..fccdc15 100644
--- a/src/lib/generator.h
+++ b/src/lib/generator.h
@@ -41,6 +41,6 @@ typedef struct
41 41
42/* Generate sources for context*/ 42/* Generate sources for context*/
43void 43void
44generator_ctx_source_generate(Gui_Context *ctx, const char *path, Generator_Export_Format format, Generator_Export_Mode mode); 44generator_ctx_source_generate(Gui_Context *ctx, Generator_Export_Format format, Generator_Export_Mode mode);
45 45
46#endif 46#endif
diff --git a/src/lib/generator_interface.eo b/src/lib/generator_interface.eo
index b91d405..b8710c8 100644
--- a/src/lib/generator_interface.eo
+++ b/src/lib/generator_interface.eo
@@ -3,7 +3,7 @@ mixin Generator_Interface () {
3 methods { 3 methods {
4 source_preamble_generate { 4 source_preamble_generate {
5 params { 5 params {
6 @in const char *project; 6 @in const Gui_Context *ctx;
7 @in Eina_Strbuf *buf; 7 @in Eina_Strbuf *buf;
8 } 8 }
9 return Eina_Bool (EINA_FALSE); 9 return Eina_Bool (EINA_FALSE);
@@ -25,7 +25,6 @@ mixin Generator_Interface () {
25 main_function_generate { 25 main_function_generate {
26 params { 26 params {
27 @in const Gui_Context *ctx; 27 @in const Gui_Context *ctx;
28 @in const char *project;
29 @in Eina_Strbuf *buf; 28 @in Eina_Strbuf *buf;
30 } 29 }
31 return Eina_Bool (EINA_FALSE); 30 return Eina_Bool (EINA_FALSE);
@@ -92,7 +91,7 @@ mixin Generator_Interface () {
92 } 91 }
93 header_preamble_generate { 92 header_preamble_generate {
94 params { 93 params {
95 @in const char *project; 94 @in const Gui_Context *ctx;
96 @in Eina_Strbuf *buf; 95 @in Eina_Strbuf *buf;
97 } 96 }
98 return Eina_Bool (EINA_FALSE); 97 return Eina_Bool (EINA_FALSE);
@@ -106,7 +105,7 @@ mixin Generator_Interface () {
106 } 105 }
107 header_main_function_generate { 106 header_main_function_generate {
108 params { 107 params {
109 @in const char *project; 108 @in const Gui_Context *ctx;
110 @in Eina_Strbuf *buf; 109 @in Eina_Strbuf *buf;
111 } 110 }
112 return Eina_Bool (EINA_FALSE); 111 return Eina_Bool (EINA_FALSE);
@@ -120,7 +119,7 @@ mixin Generator_Interface () {
120 } 119 }
121 header_postscript_generate { 120 header_postscript_generate {
122 params { 121 params {
123 @in const char *project; 122 @in const Gui_Context *ctx;
124 @in Eina_Strbuf *buf; 123 @in Eina_Strbuf *buf;
125 } 124 }
126 return Eina_Bool (EINA_FALSE); 125 return Eina_Bool (EINA_FALSE);
diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index e1072a9..93d72ef 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -70,6 +70,7 @@ struct _Gui_Context
70 Eina_List *res_arr[RESOURCE_SENTINEL]; /* List of _Gui_Resource */ 70 Eina_List *res_arr[RESOURCE_SENTINEL]; /* List of _Gui_Resource */
71 71
72 Eina_Stringshare *project_name; 72 Eina_Stringshare *project_name;
73 Eina_Stringshare *project_filename;
73 Eina_Stringshare *project_path; 74 Eina_Stringshare *project_path;
74 Eina_Hash *names_hash; /* Handle ids of names in current class: t.e. "elm_button1" */ 75 Eina_Hash *names_hash; /* Handle ids of names in current class: t.e. "elm_button1" */
75 Eina_Hash *data; /* hash to set generic data. */ 76 Eina_Hash *data; /* hash to set generic data. */
@@ -251,6 +252,18 @@ gui_context_project_name_get(const Gui_Context *ctx)
251} 252}
252 253
253void 254void
255gui_context_project_filename_set(Gui_Context *ctx, const char *filename)
256{
257 eina_stringshare_replace(&ctx->project_filename, filename);
258}
259
260Eina_Stringshare*
261gui_context_project_filename_get(const Gui_Context *ctx)
262{
263 return ctx->project_filename;
264}
265
266void
254gui_context_project_path_set(Gui_Context *ctx, const char *path) 267gui_context_project_path_set(Gui_Context *ctx, const char *path)
255{ 268{
256 eina_stringshare_replace(&ctx->project_path, path); 269 eina_stringshare_replace(&ctx->project_path, path);
@@ -349,6 +362,7 @@ gui_context_del(Gui_Context *ctx)
349 362
350 eina_stringshare_del(ctx->project_path); 363 eina_stringshare_del(ctx->project_path);
351 eina_stringshare_del(ctx->project_name); 364 eina_stringshare_del(ctx->project_name);
365 eina_stringshare_del(ctx->project_filename);
352 366
353 free(ctx); 367 free(ctx);
354 return EINA_TRUE; 368 return EINA_TRUE;
diff --git a/src/lib/gui_widget.h b/src/lib/gui_widget.h
index aa2c39a..a297339 100644
--- a/src/lib/gui_widget.h
+++ b/src/lib/gui_widget.h
@@ -167,6 +167,12 @@ Eina_Stringshare*
167gui_context_project_name_get(const Gui_Context *ctx); 167gui_context_project_name_get(const Gui_Context *ctx);
168 168
169void 169void
170gui_context_project_filename_set(Gui_Context *ctx, const char *filename);
171
172Eina_Stringshare*
173gui_context_project_filename_get(const Gui_Context *ctx);
174
175void
170gui_context_project_path_set(Gui_Context *ctx, const char *path); 176gui_context_project_path_set(Gui_Context *ctx, const char *path);
171 177
172Eina_Stringshare* 178Eina_Stringshare*