diff --git a/src/lib/Enventor_Legacy.h b/src/lib/Enventor_Legacy.h index c24a867..16c52f9 100644 --- a/src/lib/Enventor_Legacy.h +++ b/src/lib/Enventor_Legacy.h @@ -22,6 +22,11 @@ typedef struct Evas_Coord h; } Enventor_Live_View_Size; +typedef struct +{ + Eina_Bool self_changed : 1; +} Enventor_EDC_Modified; + EAPI int enventor_init(int argc, char **argv); EAPI int enventor_shutdown(void); EAPI Evas_Object *enventor_object_add(Evas_Object *parent); diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index ceb445c..da68626 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -54,6 +54,7 @@ struct editor_s Eina_Bool auto_indent : 1; Eina_Bool part_highlight : 1; Eina_Bool ctxpopup: 1; + Eina_Bool on_save : 1; }; /*****************************************************************************/ @@ -792,6 +793,18 @@ edit_view_sync_cb_set(edit_data *ed, ed->view_sync_cb_data = data; } +Eina_Bool +edit_saved_get(edit_data *ed) +{ + return ed->on_save; +} + +void +edit_saved_set(edit_data *ed, Eina_Bool saved) +{ + ed->on_save = saved; +} + Eina_Bool edit_save(edit_data *ed, const char *file) { @@ -812,6 +825,8 @@ edit_save(edit_data *ed, const char *file) edit_view_sync(ed); + ed->on_save = EINA_TRUE; + return EINA_TRUE; } diff --git a/src/lib/enventor_main.c b/src/lib/enventor_main.c index c4f6b93..afeaa1c 100644 --- a/src/lib/enventor_main.c +++ b/src/lib/enventor_main.c @@ -18,6 +18,7 @@ const char SIG_COMPILE_ERROR[] = "compile,error"; const char SIG_PROGRAM_RUN[] = "program,run"; const char SIG_CTXPOPUP_SELECTED[] = "ctxpopup,selected"; const char SIG_CTXPOPUP_DISMISSED[] = "ctxpopup,dismissed"; +const char SIG_EDC_MODIFIED[] = "edc,modified"; static int _enventor_init_count = 0; static int _enventor_log_dom = -1; diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo index 0e3ac03..5b7d66f 100644 --- a/src/lib/enventor_object.eo +++ b/src/lib/enventor_object.eo @@ -404,5 +404,6 @@ class Enventor.Object (Elm_Widget, Efl.File) { program,run; ctxpopup,selected; ctxpopup,dismissed; + edc,modified; } } diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index 3736e30..f0248ba 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -25,6 +25,7 @@ extern const char SIG_LIVE_VIEW_RESIZED[]; extern const char SIG_PROGRAM_RUN[]; extern const char SIG_CTXPOPUP_SELECTED[]; extern const char SIG_CTXPOPUP_DISMISSED[]; +extern const char SIG_EDC_MODIFIED[]; typedef struct viewer_s view_data; typedef struct syntax_color_s color_data; @@ -193,6 +194,8 @@ Eina_Bool edit_changed_get(edit_data *ed); void edit_changed_set(edit_data *ed, Eina_Bool changed); void edit_linenumber_set(edit_data *ed, Eina_Bool linenumber); Eina_Bool edit_linenumber_get(edit_data *ed); +Eina_Bool edit_saved_get(edit_data *ed); +void edit_saved_set(edit_data *ed, Eina_Bool saved); Eina_Bool edit_save(edit_data *ed, const char *file); void edit_new(edit_data* ed); void edit_view_sync_cb_set(edit_data *ed, void (*cb)(void *data, Eina_Stringshare *part_name, Eina_Stringshare *group_name), void *data); diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index bc712a6..e0a49d2 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -41,6 +41,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {SIG_PROGRAM_RUN, ""}, {SIG_CTXPOPUP_SELECTED, ""}, {SIG_CTXPOPUP_DISMISSED, ""}, + {SIG_EDC_MODIFIED, ""}, {NULL, NULL} }; @@ -52,14 +53,25 @@ file_modified_cb(void *data, int type EINA_UNUSED, void *event) { Eio_Monitor_Event *ev = event; Enventor_Object_Data *pd = data; + Enventor_EDC_Modified modified; if (ev->monitor != pd->edc_monitor) return ECORE_CALLBACK_PASS_ON; + if (!edit_saved_get(pd->ed)) + { + modified.self_changed = EINA_FALSE; + evas_object_smart_callback_call(pd->obj, SIG_EDC_MODIFIED, &modified); + return ECORE_CALLBACK_DONE; + } if (!edit_changed_get(pd->ed)) return ECORE_CALLBACK_DONE; if (strcmp(ev->filename, build_edc_path_get())) return ECORE_CALLBACK_DONE; build_edc(); edit_changed_set(pd->ed, EINA_FALSE); + edit_saved_set(pd->ed, EINA_FALSE); + modified.self_changed = EINA_TRUE; + evas_object_smart_callback_call(pd->obj, SIG_EDC_MODIFIED, &modified); + return ECORE_CALLBACK_DONE; }