jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=d27884fd2531a575ebc9a7a73e12b99019376df2

commit d27884fd2531a575ebc9a7a73e12b99019376df2
Author: Daniel Zaoui <daniel.za...@samsung.com>
Date:   Mon Nov 9 17:01:25 2015 +0200

    Updater: supply completion callback
    
    At the end of the session updates, the updater can invoke registered
    callbacks.
    This is needed if the editor wants to select the right widget and to
    update the properties view.
---
 src/lib/updater.c | 22 ++++++++++++++++++++++
 src/lib/updater.h |  7 +++++++
 2 files changed, 29 insertions(+)

diff --git a/src/lib/updater.c b/src/lib/updater.c
index 7a78a81..c41b970 100644
--- a/src/lib/updater.c
+++ b/src/lib/updater.c
@@ -9,10 +9,17 @@ static int _init_counter = 0;
 
 static Ecore_Idler *_idler = NULL;
 static Eina_List *_ctxs_to_update = NULL;
+static Eina_List *_completion_cbs = NULL;
 
 #define SESSIONS_DATA_KEY "__updater_sessions"
 #define CONTEXT_FORCE_WDGS_KEY "__updater_forced_widgets"
 
+typedef struct _completion_info
+{
+   Updater_Completion_Cb cb;
+   void *data;
+} Completion_Info;
+
 typedef struct _force_info
 {
    Eid *eid;
@@ -48,6 +55,15 @@ updater_force(Eid *eid, Updater_Force_Type type)
    updater_wake(ctx);
 }
 
+void
+updater_completion_callback_add(Updater_Completion_Cb cb, void *data)
+{
+   Completion_Info *info = calloc(1, sizeof(*info));
+   info->cb = cb;
+   info->data = data;
+   _completion_cbs = eina_list_append(_completion_cbs, info);
+}
+
 static void
 _eo_add_apply(const Eina_List *sessions, Eid *eid)
 {
@@ -110,7 +126,9 @@ _update_check(void *data EINA_UNUSED)
         Eina_List *mementos = context_memento_not_updated_list_steal(ctx, 
&mem_dir);
         if (mementos)
           {
+             Eina_List *itr2;
              Memento *mem;
+             Completion_Info *info;
              EINA_LIST_FREE(mementos, mem)
                {
                   const Eina_List *itr, *commands;
@@ -211,6 +229,10 @@ _update_check(void *data EINA_UNUSED)
                          }
                     }
                }
+             EINA_LIST_FOREACH(_completion_cbs, itr2, info)
+               {
+                  info->cb(info->data, mem, mem_dir);
+               }
           }
         Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, 
CONTEXT_FORCE_WDGS_KEY);
         Force_Info *info;
diff --git a/src/lib/updater.h b/src/lib/updater.h
index 6ae572c..c7f6bcf 100644
--- a/src/lib/updater.h
+++ b/src/lib/updater.h
@@ -1,11 +1,15 @@
 #ifndef UPDATER_H
 #define UPDATER_H
 
+#include "undoredo.h"
+
 typedef enum
 {
    UPDATER_PROPERTIES_FORCE
 } Updater_Force_Type;
 
+typedef void (*Updater_Completion_Cb)(void *data, Memento *mem, Eina_Bool dir);
+
 Eina_Bool
 updater_init();
 
@@ -19,6 +23,9 @@ void
 updater_wake(const Gui_Context *ctx);
 
 void
+updater_completion_callback_add(Updater_Completion_Cb cb, void *data);
+
+void
 updater_force(Eid *eid, Updater_Force_Type type);
 
 #endif

-- 


Reply via email to