hermet pushed a commit to branch master.

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

commit 92c09a0a39fefdee3bcf84ba949802be4150b92a
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Wed Jul 1 01:25:04 2015 +0900

    ctxpopup: support dramatic updation for live view.
    
    a little slow, but it's better than before.
    
    added smart callback, @live_view,updated
    renamed smart callback, @ctxpopup,selected -> @ctxpopup,changed
---
 src/bin/main.c             |  38 ++++-
 src/lib/ctxpopup.c         | 371 ++++++++++++++++++++++++---------------------
 src/lib/edc_editor.c       |  17 ++-
 src/lib/edj_viewer.c       |   5 +-
 src/lib/enventor_main.c    |   3 +-
 src/lib/enventor_object.eo |   3 +-
 src/lib/enventor_private.h |   5 +-
 src/lib/enventor_smart.c   |   3 +-
 8 files changed, 257 insertions(+), 188 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 621ac04..3e80188 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -10,6 +10,8 @@ typedef struct app_s
 {
    Evas_Object *enventor;
    Eina_Bool template_new : 1;
+   Eina_Bool on_saving : 1;
+   Eina_Bool lazy_save : 1;
 } app_data;
 
 int main(int argc, char **argv);
@@ -465,13 +467,39 @@ enventor_program_run_cb(void *data EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED,
 }
 
 static void
-enventor_ctxpopup_selected_cb(void *data EINA_UNUSED, Evas_Object *obj,
-                              void *event_info EINA_UNUSED)
+enventor_ctxpopup_changed_cb(void *data, Evas_Object *obj,
+                             void *event_info EINA_UNUSED)
 {
+   app_data *ad = data;
+   if (!enventor_object_modified_get(obj)) return;
+   if (ad->on_saving)
+     {
+        ad->lazy_save = EINA_TRUE;
+        return;
+     }
+   ad->on_saving = EINA_TRUE;
    enventor_object_save(obj, config_edc_path_get());
 }
 
 static void
+enventor_live_view_updated_cb(void *data, Evas_Object *obj,
+                              void *event_info EINA_UNUSED)
+{
+   app_data *ad = data;
+
+   if (ad->lazy_save && enventor_object_modified_get(obj))
+     {
+        enventor_object_save(obj, config_edc_path_get());
+        ad->lazy_save = EINA_FALSE;
+     }
+   else
+     {
+        ad->lazy_save = EINA_FALSE;
+        ad->on_saving = EINA_FALSE;
+     }
+}
+
+static void
 enventor_ctxpopup_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj,
                                void *event_info EINA_UNUSED)
 {
@@ -502,10 +530,12 @@ enventor_setup(app_data *ad)
                                   enventor_live_view_cursor_moved_cb, ad);
    evas_object_smart_callback_add(enventor, "live_view,resized",
                                   enventor_live_view_resized_cb, ad);
+   evas_object_smart_callback_add(enventor, "live_view,updated",
+                                  enventor_live_view_updated_cb, ad);
    evas_object_smart_callback_add(enventor, "program,run",
                                   enventor_program_run_cb, ad);
-   evas_object_smart_callback_add(enventor, "ctxpopup,selected",
-                                  enventor_ctxpopup_selected_cb, ad);
+   evas_object_smart_callback_add(enventor, "ctxpopup,changed",
+                                  enventor_ctxpopup_changed_cb, ad);
    evas_object_smart_callback_add(enventor, "ctxpopup,dismissed",
                                   enventor_ctxpopup_dismissed_cb, ad);
    evas_object_smart_callback_add(enventor, "focused",
diff --git a/src/lib/ctxpopup.c b/src/lib/ctxpopup.c
index 0365103..8f9b77b 100644
--- a/src/lib/ctxpopup.c
+++ b/src/lib/ctxpopup.c
@@ -8,10 +8,18 @@
 #define CTXPOPUP_BORDER_SIZE 10
 
 typedef struct ctxpopup_data_s {
-   Evas_Smart_Cb selected_cb;
+   Evas_Smart_Cb changed_cb;
    Evas_Smart_Cb relay_cb;
-   Evas_Object *ctxpopup;
    void *data;
+   Evas_Object *ctxpopup;
+   attr_value *attr;
+   char candidate[256];
+
+   /* These 2 variables are used for lazy update for slider button. */
+   Evas_Object *slider;
+   Ecore_Animator *animator;
+
+   Eina_Bool integer : 1;
 } ctxpopup_data;
 
 /*****************************************************************************/
@@ -19,116 +27,62 @@ typedef struct ctxpopup_data_s {
 /*****************************************************************************/
 
 static void
-btn_up_cb(void *data, Evas_Object *obj EINA_UNUSED,
-            void *event_info EINA_UNUSED)
+ctxpopup_it_cb(void *data, Evas_Object *obj, void *event_info)
 {
-   Evas_Object *layout = data;
-   Evas_Object *slider = elm_object_part_content_get(layout,
-                                                     "elm.swallow.slider");
-   Evas_Object *entry = elm_object_part_content_get(layout,
-                                                    "elm.swallow.entry");
-   attr_value *attr = evas_object_data_get(slider, "attr");
-   void *integer = evas_object_data_get(slider, "integer");
-   double value = elm_slider_value_get(slider);
-   char buf[128];
+   ctxpopup_data *ctxdata = data;
+   Elm_Object_Item *it = event_info;
+   const char *text = elm_object_item_text_get(it);
 
-   if (attr->type & ATTR_VALUE_INTEGER) value += 1;
-   else value += 0.01;
+   snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "%s%s%s",
+            ctxdata->attr->prepend_str, text, ctxdata->attr->append_str);
 
-   if (integer) snprintf(buf, sizeof(buf), "%1.0f", value);
-   else snprintf(buf, sizeof(buf), "%1.2f", value);
-   elm_object_text_set(entry, buf);
+   ctxdata->changed_cb(ctxdata->data, obj, ctxdata->candidate);
 }
 
 static void
-btn_down_cb(void *data, Evas_Object *obj EINA_UNUSED,
-             void *event_info EINA_UNUSED)
+ctxpopup_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+                void *event_info EINA_UNUSED)
 {
-   Evas_Object *layout = data;
-   Evas_Object *slider = elm_object_part_content_get(layout,
-                                                     "elm.swallow.slider");
-   Evas_Object *entry = elm_object_part_content_get(layout,
-                                                    "elm.swallow.entry");
-   attr_value *attr = evas_object_data_get(slider, "attr");
-   void *integer = evas_object_data_get(slider, "integer");
-   double value = elm_slider_value_get(slider);
-   char buf[128];
-
-   if (attr->type & ATTR_VALUE_INTEGER) value -= 1;
-   else value -= 0.01;
-
-   if (integer) snprintf(buf, sizeof(buf), "%1.0f", value);
-   else snprintf(buf, sizeof(buf), "%1.2f", value);
-   elm_object_text_set(entry, buf);
+   elm_config_focus_autoscroll_mode_set(ELM_FOCUS_AUTOSCROLL_MODE_SHOW);
+   ctxpopup_data *ctxdata = data;
+   ecore_animator_del(ctxdata->animator);
+   free(ctxdata);
 }
 
-static void
-ctxpopup_it_cb(void *data, Evas_Object *obj, void *event_info)
+static Eina_Bool
+changed_animator_cb(void *data)
 {
-   attr_value *attr = data;
-   Elm_Object_Item *it = event_info;
-   ctxpopup_data *ctxdata = evas_object_data_get(obj, "ctxpopup_data");
-   const char *text = elm_object_item_text_get(it);
-   char candidate[128];
-
-   snprintf(candidate, sizeof(candidate), "%s%s%s", attr->prepend_str, text,
-            attr->append_str);
-
-   ctxdata->selected_cb(ctxdata->data, obj, (void *) candidate);
+   ctxpopup_data *ctxdata = data;
+   ctxdata->changed_cb(ctxdata->data, ctxdata->ctxpopup, ctxdata->candidate);
+   ctxdata->animator = NULL;
+   return ECORE_CALLBACK_CANCEL;
 }
 
 static void
-toggle_dismiss_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+slider_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
-   attr_value *attr = data;
-   Evas_Object *box = elm_object_content_get(obj);
-   Evas_Object *layout;
-   Evas_Object *toggle;
-   Eina_List *box_children = elm_box_children_get(box);
-   Eina_List *l;
-   char candidate[512] = {0};
+   ctxpopup_data *ctxdata = data;
+   Evas_Object *entry = evas_object_data_get(obj, "entry");
+   double val = elm_slider_value_get(obj);
    char buf[128];
+   if (ctxdata->integer) snprintf(buf, sizeof(buf), "%1.0f", val);
+   else snprintf(buf, sizeof(buf), "%1.2f", val);
+   elm_object_text_set(entry, buf);
 
-   if (eina_list_count(box_children) == 0) return;
-
-   snprintf(candidate, sizeof(candidate), "%s", attr->prepend_str);
-
-   EINA_LIST_FOREACH(box_children, l, layout)
-     {
-        toggle = elm_object_part_content_get(layout,
-                                             "elm.swallow.toggle");
-        snprintf(buf, sizeof(buf), "%d", (int) elm_check_state_get(toggle));
-        strcat(candidate, buf);
-        strcat(candidate, " ");
-     }
-   candidate[strlen(candidate) - 1] = '\0'; //Remove last appended " ".
-   strcat(candidate, attr->append_str);
-
-   ctxpopup_data *ctxdata = evas_object_data_get(obj, "ctxpopup_data");
-   ctxdata->selected_cb(ctxdata->data, obj, candidate);
-}
-
-static void
-slider_dismiss_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
-{
-   attr_value *attr = data;
-   Evas_Object *box = elm_object_content_get(obj);
-   Evas_Object *layout;
-   Evas_Object *slider;
+   Evas_Object *box = elm_object_content_get(ctxdata->ctxpopup);
    Eina_List *box_children = elm_box_children_get(box);
    Eina_List *l;
-   char candidate[512] = {0};
-   char buf[128];
-
-   if (eina_list_count(box_children) == 0) return;
+   Evas_Object *layout;
+   Evas_Object *slider;
 
-   snprintf(candidate, sizeof(candidate), "%s", attr->prepend_str);
+   snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "%s",
+            ctxdata->attr->prepend_str);
 
    EINA_LIST_FOREACH(box_children, l, layout)
      {
         slider = elm_object_part_content_get(layout,
                                              "elm.swallow.slider");
-        if (attr->type & ATTR_VALUE_INTEGER)
+        if (ctxdata->attr->type & ATTR_VALUE_INTEGER)
           {
              snprintf(buf, sizeof(buf), "%d",
                       (int) roundf(elm_slider_value_get(slider)));
@@ -146,46 +100,84 @@ slider_dismiss_cb(void *data, Evas_Object *obj, void 
*event_info EINA_UNUSED)
              else
                snprintf(buf, sizeof(buf), "%0.2f", val);
           }
-        strcat(candidate, buf);
-        strcat(candidate, " ");
+        strcat(ctxdata->candidate, buf);
+        strcat(ctxdata->candidate, " ");
      }
-   candidate[strlen(candidate) - 1] = '\0'; //Remove last appended " ".
-   strcat(candidate, attr->append_str);
+   strcat(ctxdata->candidate, ctxdata->attr->append_str);
+   ctxdata->animator = ecore_animator_add(changed_animator_cb, ctxdata);
+}
 
-   ctxpopup_data *ctxdata = evas_object_data_get(obj, "ctxpopup_data");
-   ctxdata->selected_cb(ctxdata->data, obj, candidate);
+static Eina_Bool
+slider_changed_animator_cb(void *data)
+{
+   ctxpopup_data *ctxdata = data;
+   ctxdata->animator = NULL;
+   slider_changed_cb(data, ctxdata->slider, NULL);
+   return ECORE_CALLBACK_CANCEL;
 }
 
 static void
-ctxpopup_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
-                void *event_info EINA_UNUSED)
+btn_up_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
-   elm_config_focus_autoscroll_mode_set(ELM_FOCUS_AUTOSCROLL_MODE_SHOW);
-   free(data);
+   ctxpopup_data *ctxdata = data;
+   Evas_Object *layout = (Evas_Object *)evas_object_data_get(obj, "layout");
+   Evas_Object *slider = elm_object_part_content_get(layout,
+                                                     "elm.swallow.slider");
+   Evas_Object *entry = elm_object_part_content_get(layout,
+                                                    "elm.swallow.entry");
+   double value = elm_slider_value_get(slider);
+   char buf[128];
+
+   if (ctxdata->attr->type & ATTR_VALUE_INTEGER) value += 1;
+   else value += 0.01;
+
+   if (ctxdata->integer) snprintf(buf, sizeof(buf), "%1.0f", value);
+   else snprintf(buf, sizeof(buf), "%1.2f", value);
+   elm_object_text_set(entry, buf);
+
+   ctxdata->slider = slider;
+   ctxdata->animator = ecore_animator_add(slider_changed_animator_cb, ctxdata);
 }
 
 static void
-slider_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+btn_down_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
-   Evas_Object *entry = data;
-   double val = elm_slider_value_get(obj);
+   ctxpopup_data *ctxdata = data;
+   Evas_Object *layout = (Evas_Object *)evas_object_data_get(obj, "layout");
+   Evas_Object *slider = elm_object_part_content_get(layout,
+                                                     "elm.swallow.slider");
+   Evas_Object *entry = elm_object_part_content_get(layout,
+                                                    "elm.swallow.entry");
+   double value = elm_slider_value_get(slider);
    char buf[128];
-   void *integer = evas_object_data_get(obj, "integer");
 
-   if (integer) snprintf(buf, sizeof(buf), "%1.0f", val);
-   else snprintf(buf, sizeof(buf), "%1.2f", val);
+   if (ctxdata->attr->type & ATTR_VALUE_INTEGER) value -= 1;
+   else value -= 0.01;
+
+   if (ctxdata->integer) snprintf(buf, sizeof(buf), "%1.0f", value);
+   else snprintf(buf, sizeof(buf), "%1.2f", value);
    elm_object_text_set(entry, buf);
+
+   ctxdata->slider = slider;
+   ctxdata->animator = ecore_animator_add(slider_changed_animator_cb, ctxdata);
 }
 
+
+
 static void
 entry_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
-   Evas_Object *slider = data;
+   ctxpopup_data *ctxdata = data;
+   Evas_Object *slider = evas_object_data_get(obj, "slider");
    double text_val, val, min_val, max_val;
    char buf[128];
-   void *integer = evas_object_data_get(slider, "integer");
 
    text_val = atof(elm_object_text_get(obj));
+   val = elm_slider_value_get(slider);
+
+   //no change.
+   if (fabs(val - text_val) < 0.000006) return;
+
    elm_slider_min_max_get(slider, &min_val, &max_val);
 
    if (text_val < min_val) val = min_val;
@@ -194,7 +186,7 @@ entry_changed_cb(void *data, Evas_Object *obj, void 
*event_info EINA_UNUSED)
 
    if (val != text_val)
      {
-        if (integer) snprintf(buf, sizeof(buf), "%1.0f", val);
+        if (ctxdata->integer) snprintf(buf, sizeof(buf), "%1.0f", val);
         else snprintf(buf, sizeof(buf), "%1.2f", val);
         elm_object_text_set(obj, buf);
      }
@@ -202,8 +194,36 @@ entry_changed_cb(void *data, Evas_Object *obj, void 
*event_info EINA_UNUSED)
      elm_slider_value_set(slider, val);
 }
 
+static void
+toggle_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+   ctxpopup_data *ctxdata = data;
+   Evas_Object *box = elm_object_content_get(ctxdata->ctxpopup);
+   Evas_Object *layout;
+   Evas_Object *toggle;
+   Eina_List *box_children = elm_box_children_get(box);
+   Eina_List *l;
+   char buf[128];
+
+   if (eina_list_count(box_children) == 0) return;
+
+   snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "%s",
+            ctxdata->attr->prepend_str);
+
+   EINA_LIST_FOREACH(box_children, l, layout)
+     {
+        toggle = elm_object_part_content_get(layout,
+                                             "elm.swallow.toggle");
+        snprintf(buf, sizeof(buf), "%d", (int) elm_check_state_get(toggle));
+        strcat(ctxdata->candidate, buf);
+        strcat(ctxdata->candidate, " ");
+     }
+   strcat(ctxdata->candidate, ctxdata->attr->append_str);
+   ctxdata->changed_cb(ctxdata->data, ctxdata->ctxpopup, ctxdata->candidate);
+}
+
 static Evas_Object *
-toggle_layout_create(Evas_Object *parent, attr_value *attr,
+toggle_layout_create(Evas_Object *parent, ctxpopup_data *ctxdata,
                      const char *type, Eina_Bool toggle_val)
 {
    //Layout
@@ -212,23 +232,24 @@ toggle_layout_create(Evas_Object *parent, attr_value 
*attr,
    evas_object_show(layout);
 
    //Type
-   if (type)
-     elm_object_part_text_set(layout, "elm.text.type", type);
+   if (type) elm_object_part_text_set(layout, "elm.text.type", type);
 
    //Toggle
    Evas_Object *toggle = elm_check_add(layout);
    elm_object_style_set(toggle, "toggle");
+   evas_object_smart_callback_add(toggle, "changed",
+                                  toggle_changed_cb,  ctxdata);
    elm_object_part_text_set(toggle, "on", "On");
    elm_object_part_text_set(toggle, "off", "Off");
    elm_check_state_set(toggle, toggle_val);
-   evas_object_data_set(toggle, "attr", attr);
+   evas_object_data_set(toggle, "ctxdata", ctxdata);
    elm_object_part_content_set(layout, "elm.swallow.toggle", toggle);
 
    return layout;
 }
 
 static void
-toggle_layout_set(Evas_Object *ctxpopup, attr_value *attr)
+toggle_layout_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    Eina_Stringshare *type;
    Eina_Array_Iterator itr;
@@ -247,10 +268,10 @@ toggle_layout_set(Evas_Object *ctxpopup, attr_value *attr)
 
    //Layout
    Evas_Object *layout = NULL;
-   EINA_ARRAY_ITER_NEXT(attr->strs, i, type, itr)
+   EINA_ARRAY_ITER_NEXT(ctxdata->attr->strs, i, type, itr)
      {
-        layout = toggle_layout_create(box, attr, type,
-                                      (Eina_Bool) roundf(attr->val[i]));
+        layout = toggle_layout_create(box, ctxdata, type,
+                                     (Eina_Bool) 
roundf(ctxdata->attr->val[i]));
         if (i % 2) elm_object_signal_emit(layout, "odd,item,set", "");
         elm_box_pack_end(box, layout);
      }
@@ -260,24 +281,23 @@ toggle_layout_set(Evas_Object *ctxpopup, attr_value *attr)
    Evas_Object *edje = elm_layout_edje_get(layout);
    edje_object_size_min_calc(edje, &layout_w, NULL);
 
-   evas_object_smart_callback_add(ctxpopup, "dismissed", toggle_dismiss_cb,
-                                  (void *) attr);
    if (edit_w <= layout_w + CTXPOPUP_BORDER_SIZE)
      evas_object_del(ctxpopup);
 }
 
 static Evas_Object *
-slider_layout_create(Evas_Object *parent, attr_value *attr,
-                     const char *type, double slider_val, Eina_Bool integer)
+slider_layout_create(Evas_Object *parent, ctxpopup_data *ctxdata,
+                     const char *type, double slider_val)
 {
+   attr_value *attr = ctxdata->attr;
+
    //Layout
    Evas_Object *layout = elm_layout_add(parent);
    elm_layout_file_set(layout, EDJE_PATH, "slider_layout");
    evas_object_show(layout);
 
    //Type
-   if (type)
-     elm_object_part_text_set(layout, "elm.text.type", type);
+   if (type) elm_object_part_text_set(layout, "elm.text.type", type);
 
    //Slider
    Evas_Object *slider = elm_slider_add(layout);
@@ -285,12 +305,10 @@ slider_layout_create(Evas_Object *parent, attr_value 
*attr,
    elm_slider_indicator_show_set(slider, EINA_FALSE);
    elm_slider_min_max_set(slider, attr->min, attr->max);
    elm_slider_value_set(slider, slider_val);
-   evas_object_data_set(slider, "attr", attr);
-   evas_object_data_set(slider, "integer", integer ? &integer : NULL);
 
    char slider_min[16];
    char slider_max[16];
-   if (integer)
+   if (ctxdata->integer)
      {
         snprintf(slider_min, sizeof(slider_min), "%1.0f", attr->min);
         snprintf(slider_max, sizeof(slider_max), "%1.0f", attr->max);
@@ -310,14 +328,14 @@ slider_layout_create(Evas_Object *parent, attr_value 
*attr,
    elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
    elm_entry_single_line_set(entry, EINA_TRUE);
    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   if (integer) snprintf(buf, sizeof(buf), "%1.0f", slider_val);
+   if (ctxdata->integer) snprintf(buf, sizeof(buf), "%1.0f", slider_val);
    else snprintf(buf, sizeof(buf), "%1.2f", slider_val);
    elm_object_text_set(entry, buf);
    elm_object_part_content_set(layout, "elm.swallow.entry", entry);
 
    Elm_Entry_Filter_Accept_Set digits_filter_data;
    Elm_Entry_Filter_Limit_Size limit_filter_data;
-   if (integer)
+   if (ctxdata->integer)
      {
         digits_filter_data.accepted = "0123456789";
         digits_filter_data.rejected = NULL;
@@ -334,15 +352,19 @@ slider_layout_create(Evas_Object *parent, attr_value 
*attr,
    elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size,
                                   &limit_filter_data);
 
-   evas_object_smart_callback_add(slider, "changed", slider_changed_cb, entry);
-   evas_object_smart_callback_add(entry, "changed", entry_changed_cb, slider);
+   evas_object_data_set(entry, "slider", slider);
+   evas_object_data_set(slider, "entry", entry);
+   evas_object_smart_callback_add(slider, "changed", slider_changed_cb,
+                                  ctxdata);
+   evas_object_smart_callback_add(entry, "changed", entry_changed_cb, ctxdata);
 
    Evas_Object *btn;
    Evas_Object *img;
 
    //Down Button
    btn = elm_button_add(layout);
-   evas_object_smart_callback_add(btn, "clicked", btn_down_cb, layout);
+   evas_object_data_set(btn, "layout", layout);
+   evas_object_smart_callback_add(btn, "clicked", btn_down_cb, ctxdata);
    elm_object_part_content_set(layout, "elm.swallow.down", btn);
 
    //Down Image
@@ -352,7 +374,8 @@ slider_layout_create(Evas_Object *parent, attr_value *attr,
 
    //Up Button
    btn = elm_button_add(layout);
-   evas_object_smart_callback_add(btn, "clicked", btn_up_cb, layout);
+   evas_object_data_set(btn, "layout", layout);
+   evas_object_smart_callback_add(btn, "clicked", btn_up_cb, ctxdata);
    elm_object_part_content_set(layout, "elm.swallow.up", btn);
 
    //Up Image
@@ -364,7 +387,7 @@ slider_layout_create(Evas_Object *parent, attr_value *attr,
 }
 
 static void
-slider_layout_set(Evas_Object *ctxpopup, attr_value *attr, Eina_Bool integer)
+slider_layout_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    Eina_Stringshare *type;
    Eina_Array_Iterator itr;
@@ -383,57 +406,55 @@ slider_layout_set(Evas_Object *ctxpopup, attr_value 
*attr, Eina_Bool integer)
 
    //Layout
    Evas_Object *layout = NULL;
-   EINA_ARRAY_ITER_NEXT(attr->strs, i, type, itr)
+   EINA_ARRAY_ITER_NEXT(ctxdata->attr->strs, i, type, itr)
      {
-        layout = slider_layout_create(box, attr, type, attr->val[i], integer);
+        layout = slider_layout_create(box, ctxdata, type,
+                                      ctxdata->attr->val[i]);
         if (i % 2) elm_object_signal_emit(layout, "odd,item,set", "");
         elm_box_pack_end(box, layout);
      }
 
    elm_object_content_set(ctxpopup, box);
-   evas_object_smart_callback_add(ctxpopup, "dismissed", slider_dismiss_cb,
-                                  (void *) attr);
    Evas_Object *edje = elm_layout_edje_get(layout);
    edje_object_size_min_calc(edje, &layout_w, NULL);
 
    if (edit_w <= layout_w + CTXPOPUP_BORDER_SIZE)
      evas_object_del(ctxpopup);
-
 }
 
 static void
-constant_candidate_set(Evas_Object *ctxpopup, attr_value *attr)
+constant_candidate_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    Eina_Stringshare *candidate;
    Eina_Array_Iterator itr;
    unsigned int i;
 
-   EINA_ARRAY_ITER_NEXT(attr->strs, i, candidate, itr)
+   EINA_ARRAY_ITER_NEXT(ctxdata->attr->strs, i, candidate, itr)
       elm_ctxpopup_item_append(ctxpopup, candidate, NULL, ctxpopup_it_cb,
-                               (void *) attr);
+                               ctxdata);
 }
 
 static Eina_Bool
-part_candidate_set(Evas_Object *ctxpopup, attr_value *attr)
+part_candidate_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    view_data *vd = edj_mgr_view_get(NULL);
    if (!vd) return EINA_FALSE;
    Eina_List *parts = view_parts_list_get(vd);
    Eina_List *l;
    char *part;
-   char candidate[128];
    EINA_LIST_FOREACH(parts, l, part)
      {
-        snprintf(candidate, sizeof(candidate), "\"%s\"", part);
-        elm_ctxpopup_item_append(ctxpopup, candidate, NULL, ctxpopup_it_cb,
-                                 (void *) attr);
+        snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "\"%s\"",
+                 part);
+        elm_ctxpopup_item_append(ctxpopup, ctxdata->candidate, NULL,
+                                 ctxpopup_it_cb, ctxdata);
      }
    view_string_list_free(parts);
    return EINA_TRUE;
 }
 
 static Eina_Bool
-image_candidate_set(Evas_Object *ctxpopup, attr_value *attr)
+image_candidate_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    view_data *vd = edj_mgr_view_get(NULL);
    if (!vd) return EINA_FALSE;
@@ -442,32 +463,33 @@ image_candidate_set(Evas_Object *ctxpopup, attr_value 
*attr)
    char *part;
    EINA_LIST_FOREACH(parts, l, part)
       elm_ctxpopup_item_append(ctxpopup, part, NULL, ctxpopup_it_cb,
-                               (void *) attr);
+                               ctxdata);
    view_string_list_free(parts);
    return EINA_TRUE;
 }
 
 static Eina_Bool
-program_candidate_set(Evas_Object *ctxpopup, attr_value *attr)
+program_candidate_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata)
 {
    view_data *vd = edj_mgr_view_get(NULL);
    if (!vd) return EINA_FALSE;
    Eina_List *parts = view_programs_list_get(vd);
    Eina_List *l;
    char *part;
-   char candidate[128];
    EINA_LIST_FOREACH(parts, l, part)
      {
-        snprintf(candidate, sizeof(candidate), "\"%s\"", part);
-        elm_ctxpopup_item_append(ctxpopup, candidate, NULL, ctxpopup_it_cb,
-                                 (void *) attr);
+        snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "\"%s\"",
+                 part);
+        elm_ctxpopup_item_append(ctxpopup, ctxdata->candidate, NULL,
+                                 ctxpopup_it_cb, ctxdata);
      }
    view_string_list_free(parts);
    return EINA_TRUE;
 }
 
 static Eina_Bool
-state_candidate_set(Evas_Object *ctxpopup, attr_value *attr, edit_data *ed)
+state_candidate_set(Evas_Object *ctxpopup, ctxpopup_data *ctxdata,
+                    edit_data *ed)
 {
    view_data *vd = edj_mgr_view_get(NULL);
    if (!vd) return EINA_FALSE;
@@ -478,7 +500,7 @@ state_candidate_set(Evas_Object *ctxpopup, attr_value 
*attr, edit_data *ed)
    Eina_Bool ret = EINA_FALSE;
 
    //Trace the part name from the program.
-   if (attr->program)
+   if (ctxdata->attr->program)
      {
         program = edit_cur_prog_name_get(ed);
         if (!program) return EINA_FALSE;
@@ -499,23 +521,21 @@ state_candidate_set(Evas_Object *ctxpopup, attr_value 
*attr, edit_data *ed)
       values. */
    Eina_List *converted = parser_states_filtered_name_get(states);
 
-   Eina_List *l;
    char *state;
-   char candidate[128];
-   EINA_LIST_FOREACH(converted, l, state)
+   EINA_LIST_FREE(converted, state)
      {
-        snprintf(candidate, sizeof(candidate), "\"%s\"", state);
-        elm_ctxpopup_item_append(ctxpopup, candidate, NULL, ctxpopup_it_cb,
-                                 (void *) attr);
+        snprintf(ctxdata->candidate, sizeof(ctxdata->candidate), "\"%s\"",
+                 state);
+        elm_ctxpopup_item_append(ctxpopup, ctxdata->candidate, NULL,
+                                 ctxpopup_it_cb, ctxdata);
         free(state);
      }
    view_string_list_free(states);
-   eina_list_free(converted);
    ret = EINA_TRUE;
 end:
    eina_stringshare_del(program);
    view_string_list_free(targets);
-   if (!attr->program && target) eina_stringshare_del(target);
+   if (!ctxdata->attr->program && target) eina_stringshare_del(target);
    return ret;
 }
 
@@ -572,7 +592,7 @@ ctxpopup_img_preview_create(edit_data *ed,
                                        ELM_CTXPOPUP_DIRECTION_DOWN,
                                        ELM_CTXPOPUP_DIRECTION_RIGHT);
    //ctxpopup data
-   ctxpopup_data *ctxdata = malloc(sizeof(ctxpopup_data));
+   ctxpopup_data *ctxdata = calloc(1, sizeof(ctxpopup_data));
    if (!ctxdata)
      {
         EINA_LOG_ERR("Failed to allocate Memory!");
@@ -612,7 +632,7 @@ ctxpopup_img_preview_create(edit_data *ed,
 Evas_Object *
 ctxpopup_candidate_list_create(edit_data *ed, attr_value *attr,
                                Evas_Smart_Cb ctxpopup_dismiss_cb,
-                               Evas_Smart_Cb ctxpopup_selected_cb)
+                               Evas_Smart_Cb ctxpopup_changed_cb)
 {
    //create ctxpopup
    Evas_Object *ctxpopup = elm_ctxpopup_add(edit_obj_get(ed));
@@ -626,56 +646,59 @@ ctxpopup_candidate_list_create(edit_data *ed, attr_value 
*attr,
                                        ELM_CTXPOPUP_DIRECTION_UP,
                                        ELM_CTXPOPUP_DIRECTION_DOWN);
    //ctxpopup data
-   ctxpopup_data *ctxdata = malloc(sizeof(ctxpopup_data));
+   ctxpopup_data *ctxdata = calloc(1, sizeof(ctxpopup_data));
    if (!ctxdata)
      {
         EINA_LOG_ERR("Failed to allocate Memory!");
         goto err;
      }
-   ctxdata->selected_cb = ctxpopup_selected_cb;
+   ctxdata->changed_cb = ctxpopup_changed_cb;
+   ctxdata->ctxpopup = ctxpopup;
+   ctxdata->attr = attr;
    ctxdata->data = ed;
-   evas_object_data_set(ctxpopup, "ctxpopup_data", ctxdata);
 
    switch (attr->type)
      {
         case ATTR_VALUE_BOOLEAN:
           {
-             toggle_layout_set(ctxpopup, attr);
+             toggle_layout_set(ctxpopup, ctxdata);
              break;
           }
         case ATTR_VALUE_INTEGER:
           {
-             slider_layout_set(ctxpopup, attr, EINA_TRUE);
+             ctxdata->integer = EINA_TRUE;
+             slider_layout_set(ctxpopup, ctxdata);
              break;
           }
         case ATTR_VALUE_FLOAT:
           {
-             slider_layout_set(ctxpopup, attr, EINA_FALSE);
+             ctxdata->integer = EINA_FALSE;
+             slider_layout_set(ctxpopup, ctxdata);
              break;
           }
         case ATTR_VALUE_CONSTANT:
           {
-             constant_candidate_set(ctxpopup, attr);
+             constant_candidate_set(ctxpopup, ctxdata);
              break;
           }
         case ATTR_VALUE_PART:
           {
-             if (!part_candidate_set(ctxpopup, attr)) goto err;
+             if (!part_candidate_set(ctxpopup, ctxdata)) goto err;
              break;
           }
         case ATTR_VALUE_STATE:
           {
-             if (!state_candidate_set(ctxpopup, attr, ed)) goto err;
+             if (!state_candidate_set(ctxpopup, ctxdata, ed)) goto err;
              break;
           }
         case ATTR_VALUE_IMAGE:
           {
-             if (!image_candidate_set(ctxpopup, attr)) goto err;
+             if (!image_candidate_set(ctxpopup, ctxdata)) goto err;
              break;
           }
         case ATTR_VALUE_PROGRAM:
           {
-             if (!program_candidate_set(ctxpopup, attr)) goto err;
+             if (!program_candidate_set(ctxpopup, ctxdata)) goto err;
              break;
           }
    }
diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 739b20e..acc5af8 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -298,11 +298,17 @@ static void
 ctxpopup_candidate_selected_cb(void *data, Evas_Object *obj, void *event_info)
 {
    edit_data *ed = data;
+   elm_ctxpopup_dismiss(obj);
+}
+
+static void
+ctxpopup_candidate_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+   edit_data *ed = data;
    const char *text = event_info;
    char *ch;
    int cur_pos, end_pos;
    int i;
-
    cur_pos = elm_entry_cursor_pos_get(ed->en_edit);
    elm_entry_cursor_line_end_set(ed->en_edit);
    end_pos = elm_entry_cursor_pos_get(ed->en_edit);
@@ -326,9 +332,12 @@ ctxpopup_candidate_selected_cb(void *data, Evas_Object 
*obj, void *event_info)
 
    redoundo_text_relative_push(ed->rd, text);
    elm_entry_entry_insert(ed->en_edit, text);
-   elm_ctxpopup_dismiss(obj);
+   elm_entry_calc_force(ed->en_edit);
+
+   elm_entry_cursor_pos_set(ed->en_edit, cur_pos);
+
    edit_changed_set(ed, EINA_TRUE);
-   evas_object_smart_callback_call(ed->enventor, SIG_CTXPOPUP_SELECTED,
+   evas_object_smart_callback_call(ed->enventor, SIG_CTXPOPUP_CHANGED,
                                    (void *)text);
 }
 
@@ -495,7 +504,7 @@ candidate_list_show(edit_data *ed, char *text, char *cur, 
char *selected)
    Evas_Object *ctxpopup =
       ctxpopup_candidate_list_create(ed, attr,
                                      ctxpopup_candidate_dismiss_cb,
-                                     ctxpopup_candidate_selected_cb);
+                                     ctxpopup_candidate_changed_cb);
    if (!ctxpopup) return;
 
    int x, y;
diff --git a/src/lib/edj_viewer.c b/src/lib/edj_viewer.c
index 9a28da5..bc91495 100644
--- a/src/lib/edj_viewer.c
+++ b/src/lib/edj_viewer.c
@@ -210,6 +210,9 @@ exe_del_event_cb(void *data, int type EINA_UNUSED, void 
*event EINA_UNUSED)
 
    vd->edj_reload_need = EINA_FALSE;
 
+   evas_object_smart_callback_call(vd->enventor, SIG_LIVE_VIEW_UPDATED,
+                                   edj_mgr_obj_get());
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -288,7 +291,7 @@ view_obj_create(view_data *vd, const char *file_path, const 
char *group)
         vd->edj_monitor = eio_monitor_add(file_path);
         if (!vd->edj_monitor) EINA_LOG_ERR("Failed to add Eio_Monitor");
         evas_object_smart_callback_call(vd->enventor, SIG_LIVE_VIEW_LOADED,
-                                        (void*)edj_mgr_obj_get());
+                                        edj_mgr_obj_get());
      }
 
    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
diff --git a/src/lib/enventor_main.c b/src/lib/enventor_main.c
index 9af30f7..3766b92 100644
--- a/src/lib/enventor_main.c
+++ b/src/lib/enventor_main.c
@@ -11,12 +11,13 @@ Eina_Prefix *PREFIX = NULL;
 const char SIG_CURSOR_LINE_CHANGED[] = "cursor,line,changed";
 const char SIG_CURSOR_GROUP_CHANGED[]= "cursor,group,changed";
 const char SIG_LIVE_VIEW_LOADED[] = "live_view,loaded";
+const char SIG_LIVE_VIEW_UPDATED[] = "live_view,updated";
 const char SIG_LIVE_VIEW_CURSOR_MOVED[] = "live_view,cursor,moved";
 const char SIG_LIVE_VIEW_RESIZED[] = "live_view,resized";
 const char SIG_MAX_LINE_CHANGED[] = "max_line,changed";
 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_CHANGED[] = "ctxpopup,changed";
 const char SIG_CTXPOPUP_DISMISSED[] = "ctxpopup,dismissed";
 const char SIG_EDC_MODIFIED[] = "edc,modified";
 const char SIG_FOCUSED[] = "focused";
diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo
index e059a7b..9940d11 100644
--- a/src/lib/enventor_object.eo
+++ b/src/lib/enventor_object.eo
@@ -526,13 +526,14 @@ class Enventor.Object (Elm.Widget, Efl.File) {
    events {
       cursor,line,changed;
       cursor,group,changed;
+      live_view,updated;
       live_view,loaded;
       live_view,cursor,moved;
       live_view,resized;
       max_line,changed;
       compile,error;
       program,run;
-      ctxpopup,selected;
+      ctxpopup,changed;
       ctxpopup,dismissed;
       edc,modified;
       focused;
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index 34fd906..7e86206 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -24,10 +24,11 @@ extern const char SIG_CURSOR_GROUP_CHANGED[];
 extern const char SIG_MAX_LINE_CHANGED[];
 extern const char SIG_COMPILE_ERROR[];
 extern const char SIG_LIVE_VIEW_LOADED[];
+extern const char SIG_LIVE_VIEW_UPDATED[];
 extern const char SIG_LIVE_VIEW_CURSOR_MOVED[];
 extern const char SIG_LIVE_VIEW_RESIZED[];
 extern const char SIG_PROGRAM_RUN[];
-extern const char SIG_CTXPOPUP_SELECTED[];
+extern const char SIG_CTXPOPUP_CHANGED[];
 extern const char SIG_CTXPOPUP_DISMISSED[];
 extern const char SIG_EDC_MODIFIED[];
 extern const char SIG_FOCUSED[];
@@ -206,7 +207,7 @@ Eina_Bool template_insert(edit_data *ed, 
Enventor_Template_Insert_Type insert_ty
 
 
 /* ctxpopup */
-Evas_Object *ctxpopup_candidate_list_create(edit_data *ed, attr_value *attr, 
Evas_Smart_Cb ctxpopup_dismiss_cb, Evas_Smart_Cb ctxpopup_selected_cb);
+Evas_Object *ctxpopup_candidate_list_create(edit_data *ed, attr_value *attr, 
Evas_Smart_Cb ctxpopup_dismiss_cb, Evas_Smart_Cb ctxpopup_changed_cb);
 Evas_Object *ctxpopup_img_preview_create(edit_data*ed, const char *imgpath, 
Evas_Smart_Cb ctxpopup_dismiss_cb, Evas_Smart_Cb ctxpopup_relay_cb);
 
 
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index 81e775c..0bcc625 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -36,10 +36,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = 
{
    {SIG_LIVE_VIEW_CURSOR_MOVED, ""},
    {SIG_LIVE_VIEW_RESIZED, ""},
    {SIG_LIVE_VIEW_LOADED, ""},
+   {SIG_LIVE_VIEW_UPDATED, ""},
    {SIG_MAX_LINE_CHANGED, ""},
    {SIG_COMPILE_ERROR, ""},
    {SIG_PROGRAM_RUN, ""},
-   {SIG_CTXPOPUP_SELECTED, ""},
+   {SIG_CTXPOPUP_CHANGED, ""},
    {SIG_CTXPOPUP_DISMISSED, ""},
    {SIG_EDC_MODIFIED, ""},
    {SIG_FOCUSED, ""},

-- 


Reply via email to