hermet pushed a commit to branch master.

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

commit ede00648d93c9ff1250052f22f2d5bcc7de0b65c
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Fri Jan 22 19:53:32 2016 +0900

    code refactoring.
    
    remove enventor reference passing. it's avaiable to be globally accessed.
---
 src/bin/file_mgr.c      | 20 +++++++++-----------
 src/bin/live_edit.c     | 14 ++++++--------
 src/bin/main.c          |  6 +++---
 src/bin/menu.c          | 49 ++++++++++++++++++++++++-------------------------
 src/bin/newfile.c       |  7 ++++---
 src/include/file_mgr.h  |  2 +-
 src/include/live_edit.h |  2 +-
 src/include/menu.h      |  2 +-
 src/include/newfile.h   |  2 +-
 9 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/src/bin/file_mgr.c b/src/bin/file_mgr.c
index 530b037..e6bd9b0 100644
--- a/src/bin/file_mgr.c
+++ b/src/bin/file_mgr.c
@@ -6,7 +6,6 @@
 #include "common.h"
 
 typedef struct file_mgr_s {
-     Evas_Object *enventor;
      Evas_Object *warning_layout;
      Eina_Bool edc_modified : 1;
 } file_mgr_data;
@@ -20,7 +19,7 @@ warning_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
 {
    file_mgr_data *fmd = data;
    evas_object_del(fmd->warning_layout);
-   enventor_object_focus_set(fmd->enventor, EINA_TRUE);
+   enventor_object_focus_set(base_enventor_get(), EINA_TRUE);
    fmd->warning_layout = NULL;
 }
 
@@ -35,7 +34,7 @@ warning_ignore_btn_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
                       void *event_info EINA_UNUSED)
 {
    file_mgr_data *fmd = data;
-   enventor_object_modified_set(fmd->enventor, EINA_TRUE);
+   enventor_object_modified_set(base_enventor_get(), EINA_TRUE);
    warning_close(fmd);
 }
 
@@ -44,7 +43,7 @@ warning_save_as_btn_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
                        void *event_info EINA_UNUSED)
 {
    file_mgr_data *fmd = data;
-   enventor_object_modified_set(fmd->enventor, EINA_TRUE);
+   enventor_object_modified_set(base_enventor_get(), EINA_TRUE);
    menu_edc_save();
    warning_close(fmd);
 }
@@ -54,7 +53,7 @@ warning_replace_btn_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
                        void *event_info EINA_UNUSED)
 {
    file_mgr_data *fmd = data;
-   enventor_object_file_set(fmd->enventor, config_input_path_get());
+   enventor_object_file_set(base_enventor_get(), config_input_path_get());
    warning_close(fmd);
 }
 
@@ -148,8 +147,9 @@ file_mgr_edc_save(void)
    char buf[PATH_MAX];
    file_mgr_data *fmd = g_fmd;
 
-   Eina_Bool save_success = enventor_object_save(fmd->enventor, 
config_input_path_get());
-   enventor_object_modified_set(fmd->enventor, !save_success);
+   Eina_Bool save_success = enventor_object_save(base_enventor_get(),
+                                                 config_input_path_get());
+   enventor_object_modified_set(base_enventor_get(), !save_success);
 
    if (!config_stats_bar_get()) return;
 
@@ -185,7 +185,7 @@ file_mgr_warning_close(void)
 }
 
 void
-file_mgr_init(Evas_Object *enventor)
+file_mgr_init(void)
 {
    file_mgr_data *fmd = calloc(1, sizeof(file_mgr_data));
    if (!fmd)
@@ -195,9 +195,7 @@ file_mgr_init(Evas_Object *enventor)
      }
    g_fmd = fmd;
 
-   fmd->enventor = enventor;
-
-   evas_object_smart_callback_add(enventor, "edc,modified",
+   evas_object_smart_callback_add(base_enventor_get(), "edc,modified",
                                   enventor_edc_modified_cb, fmd);
 }
 
diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c
index c44c939..c3214b5 100644
--- a/src/bin/live_edit.c
+++ b/src/bin/live_edit.c
@@ -49,7 +49,6 @@ typedef struct live_editor_s
    Evas_Object *ctxpopup;
    Evas_Object *layout;
    Evas_Object *live_view;
-   Evas_Object *enventor;
    Evas_Object *trigger;
    Evas_Object *ctrl_pt[Ctrl_Pt_Cnt];
    Evas_Object *align_line[Align_Line_Cnt];
@@ -193,7 +192,7 @@ static void
 live_edit_insert(live_data *ld)
 {
    int type = CTXPOPUP_ITEMS[ld->part_info.type].type;
-   enventor_object_template_part_insert(ld->enventor,
+   enventor_object_template_part_insert(base_enventor_get(),
                                         type,
                                         ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT,
                                         ld->part_info.rel1_x,
@@ -201,7 +200,7 @@ live_edit_insert(live_data *ld)
                                         ld->part_info.rel2_x,
                                         ld->part_info.rel2_y,
                                         NULL, 0);
-   enventor_object_save(ld->enventor, config_input_path_get());
+   enventor_object_save(base_enventor_get(), config_input_path_get());
 }
 
 static Eina_Bool
@@ -988,8 +987,8 @@ live_edit_toggle(void)
 
    if (on)
      {
-        enventor_object_disabled_set(ld->enventor, EINA_TRUE);
-        ld->live_view = enventor_object_live_view_get(ld->enventor);
+        enventor_object_disabled_set(base_enventor_get(), EINA_TRUE);
+        ld->live_view = enventor_object_live_view_get(base_enventor_get());
         ld->ctxpopup = ctxpopup_create(ld);
         stats_info_msg_update(_("Select a part to add in Live View."));
         tools_live_update(EINA_TRUE);
@@ -1015,7 +1014,7 @@ live_edit_cancel(void)
 
    if (ld->ctxpopup) elm_ctxpopup_dismiss(ld->ctxpopup);
 
-   enventor_object_disabled_set(ld->enventor, EINA_FALSE);
+   enventor_object_disabled_set(base_enventor_get(), EINA_FALSE);
 
    ecore_event_handler_del(ld->key_down_handler);
    ld->key_down_handler = NULL;
@@ -1061,7 +1060,7 @@ live_edit_cancel(void)
 }
 
 void
-live_edit_init(Evas_Object *enventor, Evas_Object *trigger)
+live_edit_init(Evas_Object *trigger)
 {
    live_data *ld = calloc(1, sizeof(live_data));
    if (!ld)
@@ -1070,7 +1069,6 @@ live_edit_init(Evas_Object *enventor, Evas_Object 
*trigger)
         return;
      }
    g_ld = ld;
-   ld->enventor = enventor;
    ld->trigger = trigger;
 }
 
diff --git a/src/bin/main.c b/src/bin/main.c
index ff4bbb2..953c720 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -813,7 +813,7 @@ static void
 live_edit_set(Evas_Object *enventor, Evas_Object *tools)
 {
    Evas_Object *trigger = tools_live_edit_get(tools);
-   live_edit_init(enventor, trigger);
+   live_edit_init(trigger);
 }
 
 static void
@@ -895,7 +895,7 @@ init(app_data *ad, int argc, char **argv)
    base_gui_init();
    statusbar_set();
    enventor_setup(ad);
-   file_mgr_init(ad->enventor);
+   file_mgr_init();
    Evas_Object *tools = tools_set(ad->enventor);
    live_edit_set(ad->enventor, tools);
 
@@ -904,7 +904,7 @@ init(app_data *ad, int argc, char **argv)
    //Guarantee Enventor editor has focus.
    enventor_object_focus_set(ad->enventor, EINA_TRUE);
 
-   menu_init(ad->enventor);
+   menu_init();
 
    if (template) menu_edc_new(EINA_TRUE);
 
diff --git a/src/bin/menu.c b/src/bin/menu.c
index d621446..d3b4c42 100644
--- a/src/bin/menu.c
+++ b/src/bin/menu.c
@@ -12,8 +12,6 @@ struct menu_s
    Evas_Object *fileselector_layout;
    Evas_Object *about_layout;
 
-   Evas_Object *enventor;
-
    const char *last_accessed_path;
 
    int active_request;
@@ -126,7 +124,7 @@ newfile_ok_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                   void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   newfile_set(md->enventor, md->template_new);
+   newfile_set(md->template_new);
    newfile_close(md);
    menu_close(md);
 }
@@ -323,7 +321,7 @@ exit_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                  void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   enventor_object_save(md->enventor, config_input_path_get());
+   enventor_object_save(base_enventor_get(), config_input_path_get());
    elm_exit();
 }
 
@@ -339,7 +337,7 @@ prev_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
             void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   enventor_object_focus_set(md->enventor, EINA_TRUE);
+   enventor_object_focus_set(base_enventor_get(), EINA_TRUE);
    menu_toggle();
 }
 
@@ -371,7 +369,7 @@ new_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                 void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   enventor_object_save(md->enventor, config_input_path_get());
+   enventor_object_save(base_enventor_get(), config_input_path_get());
    newfile_open(md);
    warning_close(md);
    menu_close(md);
@@ -426,13 +424,16 @@ fileselector_save_done_cb(void *data, Evas_Object *obj, 
void *event_info)
         is_edc = EINA_TRUE;
      }
 
+   Evas_Object *enventor = base_enventor_get();
+
    if (is_edc)
      {
         config_input_path_set(selected);
         Eina_List *list = eina_list_append(NULL, config_output_path_get());
-        enventor_object_path_set(md->enventor, ENVENTOR_PATH_TYPE_EDJ, list);
+        enventor_object_path_set(enventor, ENVENTOR_PATH_TYPE_EDJ,
+                                 list);
         eina_list_free(list);
-        if (!enventor_object_save(md->enventor, selected))
+        if (!enventor_object_save(enventor, selected))
           {
              char buf[PATH_MAX];
              snprintf(buf, sizeof(buf), _("Failed to save: %s."), selected);
@@ -443,19 +444,18 @@ fileselector_save_done_cb(void *data, Evas_Object *obj, 
void *event_info)
              eina_stringshare_del(selected);
              return;
           }
-        enventor_object_file_set(md->enventor, selected);
+        enventor_object_file_set(enventor, selected);
         base_title_set(selected);
      }
    else if (is_edj)
      {
         Eina_List *edj_pathes = NULL;
         edj_pathes = eina_list_append(edj_pathes, selected);
-        enventor_object_path_set(md->enventor, ENVENTOR_PATH_TYPE_EDJ,
+        enventor_object_path_set(enventor, ENVENTOR_PATH_TYPE_EDJ,
                                  edj_pathes);
-        enventor_object_modified_set(md->enventor, EINA_TRUE);
-        enventor_object_save(md->enventor, config_input_path_get());
+        enventor_object_modified_set(enventor, EINA_TRUE);
+        enventor_object_save(enventor, config_input_path_get());
         eina_list_free(edj_pathes);
-
      }
 
    file_mgr_reset();
@@ -519,7 +519,7 @@ fileselector_load_done_cb(void *data, Evas_Object *obj, 
void *event_info)
         return;
      }
    config_input_path_set(selected);
-   enventor_object_file_set(md->enventor, selected);
+   enventor_object_file_set(base_enventor_get(), selected);
    base_title_set(selected);
    base_console_reset();
    fileselector_close(md);
@@ -615,7 +615,7 @@ load_save_btn_cb(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
                  void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   enventor_object_save(md->enventor, config_input_path_get());
+   enventor_object_save(base_enventor_get(), config_input_path_get());
    edc_file_load(md);
    warning_close(md);
 }
@@ -682,7 +682,7 @@ menu_open(menu_data *md)
 }
 
 void
-menu_init(Evas_Object *enventor)
+menu_init(void)
 {
    menu_data *md = calloc(1, sizeof(menu_data));
    if (!md)
@@ -691,8 +691,6 @@ menu_init(Evas_Object *enventor)
         return;
      }
    g_md = md;
-
-   md->enventor = enventor;
 }
 
 void
@@ -720,7 +718,7 @@ menu_edc_new(Eina_Bool template_new)
 {
    menu_data *md = g_md;
    md->template_new = template_new;
-   if (enventor_object_modified_get(md->enventor))
+   if (enventor_object_modified_get(base_enventor_get()))
      warning_open(md, new_yes_btn_cb, new_save_btn_cb);
    else
      newfile_open(md);
@@ -737,7 +735,7 @@ void
 menu_edc_load(void)
 {
    menu_data *md = g_md;
-   if (enventor_object_modified_get(md->enventor))
+   if (enventor_object_modified_get(base_enventor_get()))
      warning_open(md, load_yes_btn_cb, load_save_btn_cb);
    else
      edc_file_load(md);
@@ -802,18 +800,19 @@ void
 menu_exit(void)
 {
    menu_data *md = g_md;
-   if (enventor_object_modified_get(md->enventor))
+   Evas_Object *enventor = base_enventor_get();
+   if (enventor_object_modified_get(enventor))
      {
         search_close();
-        if (enventor_object_ctxpopup_visible_get(md->enventor))
+        if (enventor_object_ctxpopup_visible_get(enventor))
           {
              /* bacause the main.c handles the ctxpopup dismissed callback,
                 here we needs to override the function */
-             evas_object_smart_callback_priority_add(md->enventor,
+             evas_object_smart_callback_priority_add(enventor,
                                                  "ctxpopup,dismissed", 100,
                                                  
enventor_ctxpopup_dismissed_cb,
                                                  md);
-             enventor_object_ctxpopup_dismiss(md->enventor);
+             enventor_object_ctxpopup_dismiss(enventor);
           }
         else
           warning_open(md, exit_yes_btn_cb, exit_save_btn_cb);
@@ -829,7 +828,7 @@ menu_deactivate_request(void)
    md->active_request--;
 
    if (md->active_request == 0)
-     enventor_object_focus_set(md->enventor, EINA_TRUE);
+     enventor_object_focus_set(base_enventor_get(), EINA_TRUE);
    if (!md->menu_layout) return;
    elm_object_disabled_set(md->menu_layout, EINA_FALSE);
    elm_object_focus_set(md->menu_layout, EINA_TRUE);
diff --git a/src/bin/newfile.c b/src/bin/newfile.c
index 4851bd6..17e00ca 100644
--- a/src/bin/newfile.c
+++ b/src/bin/newfile.c
@@ -21,7 +21,7 @@ list_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
 }
 
 void
-newfile_set(Evas_Object *enventor, Eina_Bool template_new)
+newfile_set(Eina_Bool template_new)
 {
    new_data *nd = g_nd;
    if (!nd) return;
@@ -46,7 +46,8 @@ newfile_set(Evas_Object *enventor, Eina_Bool template_new)
         config_input_path_set(path);
 
         Eina_List *list = eina_list_append(NULL, config_output_path_get());
-        enventor_object_path_set(enventor, ENVENTOR_PATH_TYPE_EDJ, list);
+        enventor_object_path_set(base_enventor_get(), ENVENTOR_PATH_TYPE_EDJ,
+                                 list);
         eina_list_free(list);
      }
    success = eina_file_copy(buf, path,
@@ -56,7 +57,7 @@ newfile_set(Evas_Object *enventor, Eina_Bool template_new)
         EINA_LOG_ERR(_("Cannot find file! \"%s\""), buf);
         return;
      }
-   enventor_object_file_set(enventor, path);
+   enventor_object_file_set(base_enventor_get(), path);
    base_title_set(path);
    base_console_reset();
    file_mgr_reset();
diff --git a/src/include/file_mgr.h b/src/include/file_mgr.h
index 1ddc859..f565482 100644
--- a/src/include/file_mgr.h
+++ b/src/include/file_mgr.h
@@ -1,7 +1,7 @@
 Eina_Bool file_mgr_warning_is_opened(void);
 void file_mgr_warning_close(void);
 void file_mgr_warning_open(void);
-void file_mgr_init(Evas_Object *enventor);
+void file_mgr_init(void);
 void file_mgr_term(void);
 int file_mgr_edc_modified_get(void);
 void file_mgr_reset(void);
diff --git a/src/include/live_edit.h b/src/include/live_edit.h
index a2c620b..6696d2c 100644
--- a/src/include/live_edit.h
+++ b/src/include/live_edit.h
@@ -3,7 +3,7 @@
 #define LIVE_EDIT_FONT "Sans"
 #define LIVE_EDIT_FONT_SIZE 10
 
-void live_edit_init(Evas_Object *enventor, Evas_Object *trigger);
+void live_edit_init(Evas_Object *trigger);
 void live_edit_term(void);
 void live_edit_toggle(void);
 void live_edit_cancel(void);
diff --git a/src/include/menu.h b/src/include/menu.h
index 3bc99f7..49d634d 100644
--- a/src/include/menu.h
+++ b/src/include/menu.h
@@ -1,4 +1,4 @@
-void menu_init(Evas_Object *enventor);
+void menu_init(void);
 void menu_term(void);
 void menu_toggle(void);
 void menu_edc_new(Eina_Bool template_new);
diff --git a/src/include/newfile.h b/src/include/newfile.h
index da36197..31d8aca 100644
--- a/src/include/newfile.h
+++ b/src/include/newfile.h
@@ -1,4 +1,4 @@
 void newfile_default_set(Eina_Bool default_edc);
-void newfile_set(Evas_Object *enventor, Eina_Bool template_new);
+void newfile_set(Eina_Bool template_new);
 Evas_Object * newfile_create(Evas_Object *parent, Evas_Smart_Cb selected_cb, 
void *data);
 

-- 


Reply via email to