From 936fd19e35bced314112757364f1aed54df330ff Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Mon, 3 Nov 2014 13:43:13 +0900 Subject: [PATCH] ctxpopup: code refactoring clear up code. --- src/bin/main.c | 27 +++------------------------ src/lib/edc_editor.c | 13 +++++++------ src/lib/enventor_private.h | 4 ++-- src/lib/enventor_smart.c | 6 +++--- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/bin/main.c b/src/bin/main.c index 580311e..dc8b363 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -15,7 +15,6 @@ typedef struct app_s Eina_Bool ctrl_pressed : 1; Eina_Bool shift_pressed : 1; Eina_Bool template_new : 1; - Eina_Bool menu_opened : 1; } app_data; int main(int argc, char **argv); @@ -410,7 +409,6 @@ static void enventor_ctxpopup_selected_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { - EINA_LOG_ERR("!!"); enventor_object_save(obj, config_edc_path_get()); } @@ -418,8 +416,7 @@ static void enventor_ctxpopup_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { - app_data *ad = data; - if (ad->menu_opened) + if (menu_activated_get() > 0) enventor_object_focus_set(obj, EINA_FALSE); } @@ -682,7 +679,6 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev) return ECORE_CALLBACK_DONE; } - ad->menu_opened = EINA_FALSE; menu_toggle(); return ECORE_CALLBACK_DONE; } @@ -690,6 +686,8 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev) if (menu_activated_get() > 0) return ECORE_CALLBACK_PASS_ON; if (file_mgr_warning_is_opened()) return ECORE_CALLBACK_PASS_ON; + enventor_object_ctxpopup_dismiss(ad->enventor); + //Shift Key if (!strcmp("Shift_L", event->key)) { @@ -713,37 +711,24 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev) //README if (!strcmp(event->key, "F1")) { - if (enventor_object_ctxpopup_visible_get(ad->enventor)) - enventor_object_ctxpopup_dismiss(ad->enventor); - ad->menu_opened = EINA_TRUE; menu_about(); return ECORE_CALLBACK_DONE; } - //New if (!strcmp(event->key, "F2")) { - if (enventor_object_ctxpopup_visible_get(ad->enventor)) - enventor_object_ctxpopup_dismiss(ad->enventor); - ad->menu_opened = EINA_TRUE; menu_edc_new(EINA_FALSE); return ECORE_CALLBACK_DONE; } //Save if (!strcmp(event->key, "F3")) { - if (enventor_object_ctxpopup_visible_get(ad->enventor)) - enventor_object_ctxpopup_dismiss(ad->enventor); - ad->menu_opened = EINA_TRUE; menu_edc_save(); return ECORE_CALLBACK_DONE; } //Load if (!strcmp(event->key, "F4")) { - if (enventor_object_ctxpopup_visible_get(ad->enventor)) - enventor_object_ctxpopup_dismiss(ad->enventor); - ad->menu_opened = EINA_TRUE; menu_edc_load(); return ECORE_CALLBACK_DONE; } @@ -751,17 +736,14 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev) if (!strcmp(event->key, "F5")) { config_linenumber_set(!config_linenumber_get()); - enventor_object_linenumber_set(ad->enventor, config_linenumber_get()); return ECORE_CALLBACK_DONE; } - //Tools if (!strcmp(event->key, "F9")) { base_tools_toggle(EINA_TRUE); return ECORE_CALLBACK_DONE; } - //Console if (!strcmp(event->key, "F10")) { @@ -777,9 +759,6 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev) //Setting if (!strcmp(event->key, "F12")) { - if (enventor_object_ctxpopup_visible_get(ad->enventor)) - enventor_object_ctxpopup_dismiss(ad->enventor); - ad->menu_opened = EINA_TRUE; menu_setting(); return ECORE_CALLBACK_DONE; } diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index 6b1793c..275a98f 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -419,7 +419,8 @@ image_preview_show(edit_data *ed, char *cur, Evas_Coord x, Evas_Coord y) evas_object_move(ctxpopup, x, y); evas_object_show(ctxpopup); - evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb, ed); + evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, + ctxpopup_del_cb, ed); ed->ctxpopup = ctxpopup; elm_object_disabled_set(ed->layout, EINA_TRUE); succeed = EINA_TRUE; @@ -1284,16 +1285,16 @@ edit_auto_indent_get(edit_data *ed) } Eina_Bool -edit_ctxpopup_get(edit_data *ed) +edit_ctxpopup_enabled_get(edit_data *ed) { return ed->ctxpopup_enabled; } void -edit_ctxpopup_set(edit_data *ed, Eina_Bool ctxpopup) +edit_ctxpopup_enabled_set(edit_data *ed, Eina_Bool enabled) { - ctxpopup = !!ctxpopup; - ed->ctxpopup_enabled = ctxpopup; + enabled = !!enabled; + ed->ctxpopup_enabled = enabled; } Eina_Bool @@ -1305,5 +1306,5 @@ edit_ctxpopup_visible_get(edit_data *ed) void edit_ctxpopup_dismiss(edit_data *ed) { - elm_ctxpopup_dismiss(ed->ctxpopup); + if (ed->ctxpopup) elm_ctxpopup_dismiss(ed->ctxpopup); } diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index 06667c8..e5c7edf 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -221,8 +221,8 @@ void edit_auto_indent_set(edit_data *ed, Eina_Bool auto_indent); Eina_Bool edit_auto_indent_get(edit_data *ed); void edit_part_highlight_set(edit_data *ed, Eina_Bool part_highlight); Eina_Bool edit_part_highlight_get(edit_data *ed); -void edit_ctxpopup_set(edit_data *ed, Eina_Bool ctxpopup); -Eina_Bool edit_ctxpopup_get(edit_data *ed); +void edit_ctxpopup_enabled_set(edit_data *ed, Eina_Bool enabled); +Eina_Bool edit_ctxpopup_enabled_get(edit_data *ed); Eina_Bool edit_ctxpopup_visible_get(edit_data *ed); void edit_ctxpopup_dismiss(edit_data *ed); Eina_Bool edit_load(edit_data *ed, const char *edc_path); diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index 1f2adbf..f68058f 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -333,14 +333,14 @@ EOLIAN static Eina_Bool _enventor_object_ctxpopup_get(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd) { - return edit_ctxpopup_get(pd->ed); + return edit_ctxpopup_enabled_get(pd->ed); } EOLIAN static void _enventor_object_ctxpopup_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd, - Eina_Bool ctxpopup) + Eina_Bool ctxpopup) { - edit_ctxpopup_set(pd->ed, ctxpopup); + edit_ctxpopup_enabled_set(pd->ed, ctxpopup); } EOLIAN static Eina_Bool