hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=e9f258a8397676bea69d576076b323e54c55f964

commit e9f258a8397676bea69d576076b323e54c55f964
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Fri Jul 3 20:22:36 2015 +0900

    notify file changed popup correctly.
    
    Current implementation has logical hole that skips the notification of file 
changes first time.
    We fix this even if it depends on the time thresholds.
    New implementation will skip the file changes also but
    it will only skip, if the file change is happened again under 2 seconds.
---
 src/bin/file_mgr.c       | 15 ++++++---------
 src/lib/edc_editor.c     |  1 +
 src/lib/enventor_smart.c | 17 +++++++++++++----
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/bin/file_mgr.c b/src/bin/file_mgr.c
index 6e70ebe..5420cf1 100644
--- a/src/bin/file_mgr.c
+++ b/src/bin/file_mgr.c
@@ -8,7 +8,7 @@
 typedef struct file_mgr_s {
      Evas_Object *enventor;
      Evas_Object *warning_layout;
-     int edc_modified;   //1: edc is opened, 2: edc is changed
+     Eina_Bool edc_modified : 1;
 } file_mgr_data;
 
 static file_mgr_data *g_fmd = NULL;
@@ -100,7 +100,7 @@ warning_open(file_mgr_data *fmd)
 
    fmd->warning_layout = layout;
 
-   fmd->edc_modified = 0;
+   fmd->edc_modified = EINA_FALSE;
 }
 
 static void
@@ -115,14 +115,11 @@ enventor_edc_modified_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
 
    if (modified->self_changed)
      {
-        fmd->edc_modified = 0;
+        fmd->edc_modified = EINA_FALSE;
         return;
      }
 
-   //file is opened first time, we don't regard edc is modified, so skip here.
-   fmd->edc_modified++;
-
-   if (fmd->edc_modified == 1) return;
+   fmd->edc_modified = EINA_TRUE;
 
    /* FIXME: Here ignore edc changes, if any menu is closed, 
       then we need to open warning box. */
@@ -135,14 +132,14 @@ void
 file_mgr_reset(void)
 {
    file_mgr_data *fmd = g_fmd;
-   fmd->edc_modified = 0;
+   fmd->edc_modified = EINA_FALSE;
 }
 
 int
 file_mgr_edc_modified_get(void)
 {
    file_mgr_data *fmd = g_fmd;
-   return ((fmd->edc_modified == 2) ? EINA_TRUE : EINA_FALSE);
+   return fmd->edc_modified;
 }
 
 void
diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 44bff74..48fd670 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -888,6 +888,7 @@ edit_save(edit_data *ed, const char *file)
 
    edit_view_sync(ed);
 
+   edit_changed_set(ed, EINA_FALSE);
    edit_saved_set(ed, EINA_TRUE);
 
    return EINA_TRUE;
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index aeab6b1..7e9de95 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -66,28 +66,37 @@ file_modified_timer(void *data)
 static Eina_Bool
 file_modified_cb(void *data, int type EINA_UNUSED, void *event)
 {
+   static double timestamp = 0;
+   const int TIME_THRES = 2;
+
    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))
      {
+        /* FIXEME: We know this event will be called twice,
+           Skip the one event if the it's triggered in 3 seconds */
+        if (ecore_loop_time_get() - timestamp < TIME_THRES)
+          return ECORE_CALLBACK_DONE;
+
         /* Don't notify info right soon,
            if the source changing can be happened continously. */
         if (pd->file_modified_timer) ecore_timer_del(pd->file_modified_timer);
-        pd->file_modified_timer = ecore_timer_add(3, file_modified_timer, pd);
+        pd->file_modified_timer = ecore_timer_add(TIME_THRES,
+                                                  file_modified_timer, pd);
         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);
+   timestamp = ecore_loop_time_get();
 
    return ECORE_CALLBACK_DONE;
 }

-- 


Reply via email to