hermet pushed a commit to branch master.

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

commit 8679899045d230b0374292feb26c41556c302593
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Fri Jan 22 19:30:29 2016 +0900

    code refactoring.
    
    remove enventor reference passing. it's avaiable to be globally accessed.
---
 src/bin/goto.c      |  4 +--
 src/bin/main.c      | 26 ++++++++---------
 src/bin/search.c    |  4 +--
 src/bin/tools.c     | 83 ++++++++++++++++++++++++-----------------------------
 src/include/tools.h | 14 ++++-----
 5 files changed, 61 insertions(+), 70 deletions(-)

diff --git a/src/bin/goto.c b/src/bin/goto.c
index ea08885..d2be96e 100644
--- a/src/bin/goto.c
+++ b/src/bin/goto.c
@@ -199,7 +199,7 @@ goto_open(Evas_Object *enventor)
    if (!evas_object_key_grab(keygrabber, "Escape", 0, 0, EINA_TRUE))
      EINA_LOG_ERR(_("Failed to grab key - Escape"));
 
-   tools_goto_update(enventor, EINA_FALSE);
+   tools_goto_update();
 
    gd->win = win;
    gd->layout = layout;
@@ -232,5 +232,5 @@ goto_close(void)
    free(gd);
    g_gd = NULL;
 
-   tools_goto_update(enventor, EINA_FALSE);
+   tools_goto_update();
 }
diff --git a/src/bin/main.c b/src/bin/main.c
index 60fc19a..415f2b7 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -37,12 +37,12 @@ auto_indent_toggle(app_data *ad)
 }
 
 static void
-enventor_tools_update(Evas_Object *enventor)
+tools_update(void)
 {
-   tools_lines_update(enventor, EINA_FALSE);
-   tools_highlight_update(enventor, EINA_FALSE);
-   tools_dummy_update(enventor, EINA_FALSE);
-   tools_status_update(enventor, EINA_FALSE);
+   tools_lines_update(EINA_FALSE);
+   tools_highlight_update(EINA_FALSE);
+   tools_dummy_update(EINA_FALSE);
+   tools_status_update(EINA_FALSE);
 }
 
 static void
@@ -128,7 +128,7 @@ config_update_cb(void *data)
    Evas_Object *enventor = ad->enventor;
 
    enventor_common_setup(enventor);
-   enventor_tools_update(enventor);
+   tools_update();
 
    syntax_color_update(enventor);
 
@@ -214,9 +214,9 @@ main_mouse_wheel_cb(void *data, int type EINA_UNUSED, void 
*ev)
 static Evas_Object *
 tools_set(Evas_Object *enventor)
 {
-   Evas_Object *tools = tools_init(base_layout_get(), enventor);
+   Evas_Object *tools = tools_init(base_layout_get());
    base_tools_set(tools);
-   enventor_tools_update(enventor);
+   tools_update();
 
    return tools;
 }
@@ -644,13 +644,13 @@ ctrl_func(app_data *ad, Evas_Event_Key_Down *event)
    //Part Highlight
    if (!strcmp(event->key, "h") || !strcmp(event->key, "H"))
      {
-        tools_highlight_update(ad->enventor, EINA_TRUE);
+        tools_highlight_update(EINA_TRUE);
         return EINA_TRUE;
      }
    //Swallow Dummy Object
    if (!strcmp(event->key, "w") || !strcmp(event->key, "W"))
      {
-        tools_dummy_update(ad->enventor, EINA_TRUE);
+        tools_dummy_update(EINA_TRUE);
         return EINA_TRUE;
      }
    //Template Code
@@ -765,7 +765,7 @@ keygrabber_key_down_cb(void *data, Evas *e EINA_UNUSED,
    if (!strcmp(ev->key, "F5"))
      {
         enventor_object_ctxpopup_dismiss(ad->enventor);
-        tools_lines_update(ad->enventor, EINA_TRUE);
+        tools_lines_update(EINA_TRUE);
         return;
      }
    //Tools
@@ -786,7 +786,7 @@ keygrabber_key_down_cb(void *data, Evas *e EINA_UNUSED,
    if (!strcmp(ev->key, "F11"))
      {
         enventor_object_ctxpopup_dismiss(ad->enventor);
-        tools_status_update(NULL, EINA_TRUE);
+        tools_status_update(EINA_TRUE);
         return;
      }
    //Setting
@@ -804,7 +804,7 @@ statusbar_set()
 {
    Evas_Object *obj = stats_init(base_layout_get());
    elm_object_part_content_set(base_layout_get(), "elm.swallow.statusbar", 
obj);
-   tools_status_update(NULL, EINA_FALSE);
+   tools_status_update(EINA_FALSE);
 
    stats_view_scale_update(config_view_scale_get());
 }
diff --git a/src/bin/search.c b/src/bin/search.c
index 510d2cb..b888b79 100644
--- a/src/bin/search.c
+++ b/src/bin/search.c
@@ -413,7 +413,7 @@ search_open(Evas_Object *enventor)
                                btn_replace_all);
    evas_object_show(win);
 
-   tools_search_update(enventor, EINA_FALSE);
+   tools_search_update();
 
    //Keygrabber
    Evas_Object *keygrabber =
@@ -461,5 +461,5 @@ search_close(void)
    free(sd);
    g_sd = NULL;
 
-   tools_search_update(enventor, EINA_FALSE);
+   tools_search_update();
 }
diff --git a/src/bin/tools.c b/src/bin/tools.c
index 379643b..00463fa 100644
--- a/src/bin/tools.c
+++ b/src/bin/tools.c
@@ -21,13 +21,12 @@ typedef struct tools_s
 static tools_data *g_td = NULL;
 
 static void
-menu_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+menu_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+        void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-
    if (live_edit_get()) live_edit_cancel();
    if (search_is_opened()) search_close();
-   if (goto_is_opened()) tools_goto_update(enventor, EINA_TRUE);
+   if (goto_is_opened()) tools_goto_update();
 
    menu_toggle();
 }
@@ -36,50 +35,45 @@ static void
 highlight_cb(void *data, Evas_Object *obj EINA_UNUSED,
              void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-   tools_highlight_update(enventor, EINA_TRUE);
+   tools_highlight_update(EINA_TRUE);
 }
 
 static void
 dummy_cb(void *data, Evas_Object *obj EINA_UNUSED,
            void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-   tools_dummy_update(enventor, EINA_TRUE);
+   tools_dummy_update(EINA_TRUE);
 }
 
 static void
 lines_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-   tools_lines_update(enventor, EINA_TRUE);
+   tools_lines_update(EINA_TRUE);
 }
 
 static void
 status_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
           void *event_info EINA_UNUSED)
 {
-   tools_status_update(NULL, EINA_TRUE);
+   tools_status_update(EINA_TRUE);
 }
 
 static void
 find_cb(void *data, Evas_Object *obj EINA_UNUSED,
         void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
    live_edit_cancel();
    if (search_is_opened()) search_close();
-   else search_open(enventor);
+   else search_open(base_enventor_get());
 }
 
 static void
 goto_cb(void *data, Evas_Object *obj EINA_UNUSED,
         void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
    live_edit_cancel();
    if (goto_is_opened()) goto_close();
-   else goto_open(enventor);
+   else goto_open(base_enventor_get());
 }
 
 static void
@@ -109,11 +103,10 @@ save_cb(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
 }
 
 static void
-redo_cb(void *data, Evas_Object *obj EINA_UNUSED,
+redo_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
         void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-   if (enventor_object_redo(enventor))
+   if (enventor_object_redo(base_enventor_get()))
      stats_info_msg_update(_("Redo text."));
    else
      stats_info_msg_update(_("No text to be redo."));
@@ -123,8 +116,7 @@ static void
 undo_cb(void *data, Evas_Object *obj EINA_UNUSED,
         void *event_info EINA_UNUSED)
 {
-   Evas_Object *enventor = data;
-   if (enventor_object_undo(enventor))
+   if (enventor_object_undo(base_enventor_get()))
      stats_info_msg_update(_("Undo text."));
    else
      stats_info_msg_update(_("No text to be undo."));
@@ -132,7 +124,7 @@ undo_cb(void *data, Evas_Object *obj EINA_UNUSED,
 
 static Evas_Object *
 tools_btn_create(Evas_Object *parent, const char *icon,
-                 const char *tooltip_msg, Evas_Smart_Cb func, void *data)
+                 const char *tooltip_msg, Evas_Smart_Cb func)
 {
    Evas_Object *btn = elm_button_add(parent);
    elm_object_style_set(btn, elm_app_name_get());
@@ -144,7 +136,7 @@ tools_btn_create(Evas_Object *parent, const char *icon,
    elm_image_file_set(img, EDJE_PATH, icon);
    elm_object_content_set(btn, img);
 
-   evas_object_smart_callback_add(btn, "clicked", func, data);
+   evas_object_smart_callback_add(btn, "clicked", func, NULL);
    evas_object_show(btn);
 
    return btn;
@@ -159,7 +151,7 @@ tools_term(void)
 }
 
 Evas_Object *
-tools_init(Evas_Object *parent, Evas_Object *enventor)
+tools_init(Evas_Object *parent)
 {
    tools_data *td = g_td;
    if (td) return (td->box);
@@ -181,7 +173,7 @@ tools_init(Evas_Object *parent, Evas_Object *enventor)
 
    Evas_Object *btn;
    btn = tools_btn_create(box, "menu", _("Enventor Menu (Esc)"),
-                          menu_cb, enventor);
+                          menu_cb);
    elm_object_tooltip_orient_set(btn, ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
@@ -194,39 +186,39 @@ tools_init(Evas_Object *parent, Evas_Object *enventor)
    elm_box_pack_end(box, sp);
 
    btn = tools_btn_create(box, "save",_("Save File (Ctrl + S)"),
-                          save_cb, enventor);
+                          save_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
 
    btn = tools_btn_create(box, "undo", _("Undo Text (Ctrl + Z)"),
-                          undo_cb, enventor);
+                          undo_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
 
    btn = tools_btn_create(box, "redo", _("Redo Text (Ctrl + R)"),
-                          redo_cb, enventor);
+                          redo_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
 
    btn = tools_btn_create(box, "find", _("Find/Replace (Ctrl + F)"),
-                          find_cb, enventor);
+                          find_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    td->find_btn = btn;
 
    btn = tools_btn_create(box, "goto", _("Goto Lines (Ctrl + L)"),
-                          goto_cb, enventor);
+                          goto_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    td->goto_btn = btn;
 
    btn = tools_btn_create(box, "lines", _("Line Numbers (F5)"),
-                          lines_cb, enventor);
+                          lines_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
@@ -237,21 +229,21 @@ tools_init(Evas_Object *parent, Evas_Object *enventor)
    elm_box_pack_end(box, sp);
 
    btn = tools_btn_create(box, "highlight", _("Part Highlighting (Ctrl + H)"),
-                          highlight_cb, enventor);
+                          highlight_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    td->highlight_btn = btn;
 
    btn = tools_btn_create(box, "dummy", _("Dummy Parts (Ctrl + W)"),
-                          dummy_cb, enventor);
+                          dummy_cb);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    td->swallow_btn = btn;
 
    btn = tools_btn_create(box, "live_edit", _("Live View Edit (Ctrl + E)"),
-                          live_edit_cb, enventor);
+                          live_edit_cb);
    evas_object_size_hint_weight_set(btn, 0.0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
@@ -269,14 +261,14 @@ tools_init(Evas_Object *parent, Evas_Object *enventor)
    elm_box_pack_end(box, sp);
 
    btn = tools_btn_create(box, "console", _("Console Box (Alt + Down)"),
-                          console_cb, NULL);
+                          console_cb);
    elm_object_tooltip_orient_set(btn, ELM_TOOLTIP_ORIENT_BOTTOM_LEFT);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 1.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    td->console_btn = btn;
 
-   btn = tools_btn_create(box, "status", _("Status (F11)"), status_cb, NULL);
+   btn = tools_btn_create(box, "status", _("Status (F11)"), status_cb);
    elm_object_tooltip_orient_set(btn, ELM_TOOLTIP_ORIENT_BOTTOM_LEFT);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 1.0, EVAS_HINT_FILL);
@@ -301,13 +293,13 @@ tools_live_edit_get(Evas_Object *tools)
 }
 
 void
-tools_highlight_update(Evas_Object *enventor, Eina_Bool toggle)
+tools_highlight_update(Eina_Bool toggle)
 {
    tools_data *td = g_td;
    if (!td) return;
 
    if (toggle) config_part_highlight_set(!config_part_highlight_get());
-   enventor_object_part_highlight_set(enventor,
+   enventor_object_part_highlight_set(base_enventor_get(),
                                       config_part_highlight_get());
    if (toggle)
      {
@@ -325,13 +317,13 @@ tools_highlight_update(Evas_Object *enventor, Eina_Bool 
toggle)
 }
 
 void
-tools_lines_update(Evas_Object *enventor, Eina_Bool toggle)
+tools_lines_update(Eina_Bool toggle)
 {
    tools_data *td = g_td;
    if (!td) return;
 
    if (toggle) config_linenumber_set(!config_linenumber_get());
-   enventor_object_linenumber_set(enventor, config_linenumber_get());
+   enventor_object_linenumber_set(base_enventor_get(), 
config_linenumber_get());
 
    //Toggle on/off
    if (config_linenumber_get())
@@ -341,13 +333,14 @@ tools_lines_update(Evas_Object *enventor, Eina_Bool 
toggle)
 }
 
 void
-tools_dummy_update(Evas_Object *enventor, Eina_Bool toggle)
+tools_dummy_update(Eina_Bool toggle)
 {
    tools_data *td = g_td;
    if (!td) return;
 
    if (toggle) config_dummy_parts_set(!config_dummy_parts_get());
-   enventor_object_dummy_parts_set(enventor, config_dummy_parts_get());
+   enventor_object_dummy_parts_set(base_enventor_get(),
+                                   config_dummy_parts_get());
 
    if (toggle)
      {
@@ -364,7 +357,7 @@ tools_dummy_update(Evas_Object *enventor, Eina_Bool toggle)
 }
 
 void
-tools_status_update(Evas_Object *enventor EINA_UNUSED, Eina_Bool toggle)
+tools_status_update(Eina_Bool toggle)
 {
    tools_data *td = g_td;
    if (!td) return;
@@ -379,8 +372,7 @@ tools_status_update(Evas_Object *enventor EINA_UNUSED, 
Eina_Bool toggle)
 }
 
 void
-tools_goto_update(Evas_Object *enventor EINA_UNUSED,
-                  Eina_Bool toggle EINA_UNUSED)
+tools_goto_update(void)
 {
    tools_data *td = g_td;
    if (!td) return;
@@ -392,8 +384,7 @@ tools_goto_update(Evas_Object *enventor EINA_UNUSED,
 }
 
 void
-tools_search_update(Evas_Object *enventor EINA_UNUSED,
-                    Eina_Bool toggle EINA_UNUSED)
+tools_search_update(void)
 {
    tools_data *td = g_td;
    if (!td) return;
diff --git a/src/include/tools.h b/src/include/tools.h
index 81491ac..33a2bc3 100644
--- a/src/include/tools.h
+++ b/src/include/tools.h
@@ -1,12 +1,12 @@
-Evas_Object *tools_init(Evas_Object *parent, Evas_Object *enventor);
+Evas_Object *tools_init(Evas_Object *parent);
 void tools_term(void);
 Evas_Object *tools_live_edit_get(Evas_Object *tools);
-void tools_highlight_update(Evas_Object *enventor, Eina_Bool toggle);
-void tools_lines_update(Evas_Object *enventor, Eina_Bool toggle);
-void tools_dummy_update(Evas_Object *enventor, Eina_Bool toggle);
-void tools_status_update(Evas_Object *enventor, Eina_Bool toggle);
-void tools_goto_update(Evas_Object *enventor, Eina_Bool toggle);
-void tools_search_update(Evas_Object *enventor, Eina_Bool toggle);
+void tools_highlight_update(Eina_Bool toggle);
+void tools_lines_update(Eina_Bool toggle);
+void tools_dummy_update(Eina_Bool toggle);
+void tools_status_update(Eina_Bool toggle);
+void tools_goto_update(void);
+void tools_search_update(void);
 void tools_live_update(Eina_Bool on);
 void tools_console_update(Eina_Bool on);
 void tools_menu_update(Eina_Bool on);

-- 


Reply via email to