yakov pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=a04d1faa70da2c861c96a94ff75aa7a5387f6d40
commit a04d1faa70da2c861c96a94ff75aa7a5387f6d40 Author: Yakov Goldberg <yako...@samsung.com> Date: Thu Nov 12 14:00:41 2015 +0200 Refactoring _canvas_name_update() Add parameter to be able to set canvas name with star: '*project_name' when project is not saved --- src/bin/gui/editor.c | 16 ++++++++++++---- src/bin/gui/egui_logic.c | 20 ++++++++++---------- src/bin/gui/egui_logic_private.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c index fdeee66..5f58411 100644 --- a/src/bin/gui/editor.c +++ b/src/bin/gui/editor.c @@ -90,9 +90,16 @@ _active_context_get() } void -_canvas_name_update(const Gui_Context *ctx) +_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; + if ((prev_editing == editing) && (ctx == prev_ctx)) return; + prev_editing = editing; + prev_ctx = ctx; + char name[100]; if (!ctx) { @@ -102,7 +109,7 @@ _canvas_name_update(const Gui_Context *ctx) { project_name = gui_context_project_name_get(ctx); if (!project_name) project_name = "untitled"; - sprintf(name, "Erigo - %s", project_name); + sprintf(name, "Erigo - %s%s", editing ? "*" : "", project_name); } eo_do(g->main_win->main_win, elm_obj_win_title_set(name)); @@ -113,7 +120,8 @@ _canvas_name_update(const Gui_Context *ctx) if (glit) { - eo_do(glit, elm_wdg_item_part_text_set(NULL, project_name)); + sprintf(name, "%s%s", editing ? "*" : "", project_name); + eo_do(glit, elm_wdg_item_part_text_set(NULL, name)); } } @@ -3850,7 +3858,7 @@ _switch_to_context(Gui_Context *ctx) _editor_wdg_selected_set(wdg); objtree_item_selected_set(wdg); _canvas_resize_cb(NULL, g->main_win->canvas_scroller, NULL, NULL); - _canvas_name_update(ctx); + _canvas_name_update(ctx, EINA_FALSE); Eina_Stringshare *theme_name = gui_context_edit_theme_name_get(_active_context_get()); eo_do(g->main_win->theme_selector_hoversel, elm_obj_widget_part_text_set(NULL, THEME_NAME_GET(theme_name))); _theme_selector_hover_selected_cb(NULL, NULL, NULL, NULL); diff --git a/src/bin/gui/egui_logic.c b/src/bin/gui/egui_logic.c index 2e3e137..fa6cafe 100644 --- a/src/bin/gui/egui_logic.c +++ b/src/bin/gui/egui_logic.c @@ -160,7 +160,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); + _canvas_name_update(ctx, EINA_FALSE); free(parent_dir); /* Close fileselector win. */ @@ -198,7 +198,7 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event) if (_guilogic_cbs->_project_new(path)) { ctx = _active_context_get(); - _canvas_name_update(ctx); + _canvas_name_update(ctx, EINA_FALSE); /* If no more free contexts, disable items. */ if (!gui_context_free_is()) { @@ -229,7 +229,7 @@ _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); + _canvas_name_update(ctx, EINA_FALSE); /* If no more free contexts, disable items. */ if (!gui_context_free_is()) { @@ -270,7 +270,7 @@ _on_fs_done(void *data, Evas_Object *obj EINA_UNUSED, void *event) 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); + _canvas_name_update(ctx, EINA_FALSE); free(default_filename); } break; @@ -324,7 +324,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); + _canvas_name_update(ctx, EINA_FALSE); } break; } @@ -470,7 +470,7 @@ _project_menu_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_ _active_context_set(NULL); _context_toolbar_item_delete(close_ctx); - _canvas_name_update(_active_context_get()); + _canvas_name_update(_active_context_get(), EINA_FALSE); _menu_item_disabled_set(project_menu, ITEM_OPEN, EINA_FALSE); _menu_item_disabled_set(project_menu, ITEM_NEW, EINA_FALSE); /* If no more opened contexts, disable items. */ @@ -494,7 +494,7 @@ _project_menu_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_ return; } generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx); + _canvas_name_update(ctx, EINA_FALSE); break; } case ITEM_SAVEAS: @@ -769,7 +769,7 @@ _key_binding_save_cb(void *data) return; } generator_ctx_source_generate(ctx, GENERATE_JSON, EINA_FALSE); - _canvas_name_update(ctx); + _canvas_name_update(ctx, EINA_FALSE); } else if (action == ITEM_SAVEAS) { @@ -805,7 +805,7 @@ _egui_project_open(const char *path) 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); + _canvas_name_update(ctx, EINA_FALSE); free(_dir); post_open = EINA_TRUE; @@ -814,7 +814,7 @@ _egui_project_open(const char *path) if (post_open) { - _canvas_name_update(_active_context_get()); + _canvas_name_update(_active_context_get(), EINA_FALSE); /* If no more free contexts, disable items. */ if (!gui_context_free_is()) { diff --git a/src/bin/gui/egui_logic_private.h b/src/bin/gui/egui_logic_private.h index 8ec5541..29a17fa 100644 --- a/src/bin/gui/egui_logic_private.h +++ b/src/bin/gui/egui_logic_private.h @@ -28,7 +28,7 @@ Gui_Context * _active_context_get(); void -_canvas_name_update(const Gui_Context *ctx); +_canvas_name_update(const Gui_Context *ctx, Eina_Bool not_saved); Eo * canvas_get(); --