summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-22 16:20:11 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-22 16:20:11 +0300
commit962b98accddd15e756dc3000bdbb922b3138b6ec (patch)
treec64b8e6c3ceecb9cbd36a1b9d4d99bf69e920f0d
parentb9758617cd0b57c3a2e507523e0ece0f82782390 (diff)
small refactoring of gui generate func
-rw-r--r--src/bin/egui_gui/egui_logic.c7
-rw-r--r--src/bin/main.c17
-rw-r--r--src/lib/generator.c7
-rw-r--r--src/lib/generator.h2
4 files changed, 19 insertions, 14 deletions
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index 9944a2a..46283e8 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 generator_ctx_source_generate(_active_context_get(), parent_dir, filename);
176 gui_context_project_name_set(_active_context_get(), filename); 175 gui_context_project_name_set(_active_context_get(), filename);
177 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);
178 _canvas_name_update(_active_context_get()); 178 _canvas_name_update(_active_context_get());
179 } 179 }
180 free(parent_dir); 180 free(parent_dir);
@@ -281,13 +281,12 @@ _project_save(Gui_Context *ctx)
281{ 281{
282 if (!ctx) return; 282 if (!ctx) return;
283 const char *dir = gui_context_project_path_get(ctx); 283 const char *dir = gui_context_project_path_get(ctx);
284 const char *project = gui_context_project_name_get(ctx); 284 if (!dir)
285 if ((!dir) || (!project))
286 { 285 {
287 _fs_save_as_open(); 286 _fs_save_as_open();
288 return; 287 return;
289 } 288 }
290 generator_ctx_source_generate(ctx, dir, project); 289 generator_ctx_source_generate(ctx, dir);
291} 290}
292 291
293static void 292static void
diff --git a/src/bin/main.c b/src/bin/main.c
index e79d342..fce270e 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 *project) 14_generate(const char *filename, const char* path, const char *new_project_name)
15{ 15{
16 Gui_Context *ctx; 16 Gui_Context *ctx;
17 ctx = gui_context_new();; 17 ctx = gui_context_new();;
@@ -27,7 +27,12 @@ _generate(const char *filename, const char* path, const char *project)
27 return EINA_FALSE; 27 return EINA_FALSE;
28 } 28 }
29 29
30 generator_ctx_source_generate(ctx, path, project); 30 /* if new_project_name is no NULL, we want to put new project name. */
31 if (new_project_name)
32 {
33 gui_context_project_name_set(ctx, new_project_name);
34 }
35 generator_ctx_source_generate(ctx, path);
31 gui_context_del(ctx); 36 gui_context_del(ctx);
32 return EINA_TRUE; 37 return EINA_TRUE;
33} 38}
@@ -96,7 +101,7 @@ _manager_init_check();
96int 101int
97main(int argc, char **argv) 102main(int argc, char **argv)
98{ 103{
99 const char *path = ".", *name = NULL, *target_name = NULL; 104 const char *path = ".", *new_project_name = NULL, *target_name = NULL;
100 char *filename = NULL; 105 char *filename = NULL;
101 const char *mode = NULL; 106 const char *mode = NULL;
102 int i; 107 int i;
@@ -150,7 +155,7 @@ main(int argc, char **argv)
150 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1))) 155 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
151 { 156 {
152 i++; 157 i++;
153 name = argv[i]; 158 new_project_name = argv[i];
154 } 159 }
155 } 160 }
156 161
@@ -176,14 +181,14 @@ main(int argc, char **argv)
176 } 181 }
177 else if (!strcmp(mode, "-g")) 182 else if (!strcmp(mode, "-g"))
178 { 183 {
179 if ((!name) || (!filename)) 184 if (!filename)
180 { 185 {
181 _help(); 186 _help();
182 return 1; 187 return 1;
183 } 188 }
184 else 189 else
185 { 190 {
186 _generate(filename, path, name); 191 _generate(filename, path, new_project_name);
187 } 192 }
188 } 193 }
189 194
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 64fb39e..02ec7b9 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -615,8 +615,9 @@ _resources_to_json(const Gui_Context *ctx)
615 615
616/* Save context into "project" files. */ 616/* Save context into "project" files. */
617static void 617static void
618_ctx_to_file_save(Gui_Context *ctx, const char *path, const char *project) 618_ctx_to_file_save(Gui_Context *ctx, const char *path)
619{ 619{
620 const char *project = gui_context_project_name_get(ctx);
620 char *filename_c = (char *) calloc(strlen(path) + strlen(project) + 4, 1); 621 char *filename_c = (char *) calloc(strlen(path) + strlen(project) + 4, 1);
621 char *filename_h = (char *) calloc(strlen(path) + strlen(project) + 4, 1); 622 char *filename_h = (char *) calloc(strlen(path) + strlen(project) + 4, 1);
622 FILE *fp_c, *fp_h; 623 FILE *fp_c, *fp_h;
@@ -736,7 +737,7 @@ end:
736} 737}
737 738
738void 739void
739generator_ctx_source_generate(Gui_Context *ctx, const char *path, const char *project) 740generator_ctx_source_generate(Gui_Context *ctx, const char *path)
740{ 741{
741 if (!gui_context_win_list_get(ctx)) 742 if (!gui_context_win_list_get(ctx))
742 { 743 {
@@ -755,7 +756,7 @@ generator_ctx_source_generate(Gui_Context *ctx, const char *path, const char *pr
755 funcs->content_set = _content_set_generate; 756 funcs->content_set = _content_set_generate;
756 funcs->item_add = _item_add_generate; 757 funcs->item_add = _item_add_generate;
757 758
758 _ctx_to_file_save(ctx, path, project); 759 _ctx_to_file_save(ctx, path);
759} 760}
760 761
761 762
diff --git a/src/lib/generator.h b/src/lib/generator.h
index e70c479..dc82a35 100644
--- a/src/lib/generator.h
+++ b/src/lib/generator.h
@@ -27,6 +27,6 @@ typedef struct
27 27
28/* Generate sources for context*/ 28/* Generate sources for context*/
29void 29void
30generator_ctx_source_generate(Gui_Context *ctx, const char *path, const char *project); 30generator_ctx_source_generate(Gui_Context *ctx, const char *path);
31 31
32#endif 32#endif