yakov pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=ba00fb7f630ede43d98e3aa7585943cfb1b86fdc
commit ba00fb7f630ede43d98e3aa7585943cfb1b86fdc Author: Yakov Goldberg <yako...@samsung.com> Date: Thu Nov 12 16:58:51 2015 +0200 Add wrapper _context_save() --- src/bin/gui/editor.c | 17 ++++++++--------- src/bin/gui/egui_logic.c | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c index 5f58411..3802688 100644 --- a/src/bin/gui/editor.c +++ b/src/bin/gui/editor.c @@ -92,26 +92,23 @@ _active_context_get() void _canvas_name_update(const Gui_Context *ctx, Eina_Bool editing) { - const char* project_name = NULL; - static Eina_Bool prev_editing; static const Gui_Context *prev_ctx; + char name[200]; + char win_title[300]; + if ((prev_editing == editing) && (ctx == prev_ctx)) return; prev_editing = editing; prev_ctx = ctx; - char name[100]; if (!ctx) { - sprintf(name, "Erigo - EFL GUI Builder"); + sprintf(name, "EFL GUI Builder"); } else { - project_name = gui_context_project_name_get(ctx); - if (!project_name) project_name = "untitled"; - sprintf(name, "Erigo - %s%s", editing ? "*" : "", project_name); + sprintf(name, "%s%s", editing ? "*" : "", gui_context_project_name_get(ctx)); } - eo_do(g->main_win->main_win, elm_obj_win_title_set(name)); /* Find item according to context. */ Elm_Object_Item *glit = elm_toolbar_first_item_get(g->main_win->context_toolbar); @@ -120,9 +117,11 @@ _canvas_name_update(const Gui_Context *ctx, Eina_Bool editing) if (glit) { - sprintf(name, "%s%s", editing ? "*" : "", project_name); eo_do(glit, elm_wdg_item_part_text_set(NULL, name)); } + + sprintf(win_title, "Erigo - %s", name); + eo_do(g->main_win->main_win, elm_obj_win_title_set(win_title)); } typedef enum { diff --git a/src/bin/gui/egui_logic.c b/src/bin/gui/egui_logic.c index fa6cafe..fa7c51b 100644 --- a/src/bin/gui/egui_logic.c +++ b/src/bin/gui/egui_logic.c @@ -145,6 +145,13 @@ _menu_item_disabled_set(Eo *menu, intptr_t _item_type, Eina_Bool disabled) elm_object_item_disabled_set(it, disabled); } +static void +_context_save(const Gui_Context *ctx) +{ + generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); + _canvas_name_update(ctx, EINA_FALSE); +} + /* Callback to be called after clicking popup button */ static void _popup_cb(Popup_Button_Type button_type, void *data) @@ -159,8 +166,7 @@ _popup_cb(Popup_Button_Type button_type, void *data) gui_context_project_filename_set((Gui_Context *) ctx, filename); gui_context_project_path_set((Gui_Context *) ctx, (const char *) parent_dir); - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); free(parent_dir); /* Close fileselector win. */ @@ -229,7 +235,6 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event) if (_guilogic_cbs->_project_new(NULL)) { ctx = _active_context_get(); - _canvas_name_update(ctx, EINA_FALSE); /* If no more free contexts, disable items. */ if (!gui_context_free_is()) { @@ -269,8 +274,7 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event) gui_context_project_name_set((Gui_Context *) ctx, project_name); gui_context_project_path_set((Gui_Context *) ctx, path); gui_context_project_filename_set((Gui_Context *) ctx, full_filename); - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); free(default_filename); } break; @@ -323,8 +327,7 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event) { gui_context_project_filename_set((Gui_Context *) ctx, filename); gui_context_project_path_set((Gui_Context *) ctx, (const char *) parent_dir); - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); } break; } @@ -493,8 +496,7 @@ _project_menu_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_ _fs_mode_open(ITEM_SAVEAS); return; } - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); break; } case ITEM_SAVEAS: @@ -768,8 +770,7 @@ _key_binding_save_cb(void *data) _fs_mode_open(ITEM_SAVEAS); return; } - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); } else if (action == ITEM_SAVEAS) { @@ -804,8 +805,7 @@ _egui_project_open(const char *path) gui_context_project_name_set((Gui_Context *) ctx, filename); gui_context_project_path_set((Gui_Context *) ctx, _dir); gui_context_project_filename_set((Gui_Context *) ctx, filename); - generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx, EINA_FALSE); + _context_save(ctx); free(_dir); post_open = EINA_TRUE; --