hermet pushed a commit to branch master.

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

commit 5a4d2baaf3f160e4bbfb2c88efbd1497ce4fba33
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Thu Mar 13 03:54:03 2014 +0900

    newfile - open real "new" template code when NEW file is requested.
    
    previously, it doesn't open a new template code but modified one.
    now it's fixed.
---
 src/bin/Makefile.am      |  1 +
 src/bin/edc_editor.c     |  9 +++++++++
 src/bin/main.c           | 20 +-------------------
 src/bin/menu.c           | 21 +++++----------------
 src/bin/newfile.c        | 21 +++++++++++++++++++++
 src/include/Makefile.am  |  1 +
 src/include/common.h     |  1 +
 src/include/edc_editor.h |  1 +
 src/include/newfile.h    |  1 +
 9 files changed, 41 insertions(+), 35 deletions(-)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 29e0f9a..e614c7b 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -28,6 +28,7 @@ enventor_SOURCES = \
        build.c \
        tools.c \
        search.c \
+       newfile.c \
        globals.c
 
 enventor_LDADD = @ENVENTOR_LIBS@
diff --git a/src/bin/edc_editor.c b/src/bin/edc_editor.c
index 04e2358..f2c95db 100644
--- a/src/bin/edc_editor.c
+++ b/src/bin/edc_editor.c
@@ -927,3 +927,12 @@ edit_part_highlight_toggle(edit_data *ed, Eina_Bool msg)
    else
      stats_info_msg_update("Part Highlighting Disabled.");
 }
+
+void
+edit_edc_reload(edit_data *ed, const char *edc_path)
+{
+   config_edc_path_set(edc_path);
+   edit_new(ed);
+   edj_mgr_reload_need_set(EINA_TRUE);
+   config_apply();
+}
diff --git a/src/bin/main.c b/src/bin/main.c
index 878a89a..7bdd653 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -36,25 +36,7 @@ edc_changed_cb(void *data, int type EINA_UNUSED, void *event)
 static Eina_Bool
 edc_proto_setup()
 {
-   Eina_Bool success = EINA_TRUE;
-
-   char buf[PATH_MAX];
-   snprintf(buf, sizeof(buf), "%s/.proto/proto.edc",
-            elm_app_data_dir_get());
-
-   if (!ecore_file_exists(config_edc_path_get()))
-     {
-        EINA_LOG_INFO("No working edc file exists. Copy a proto.edc");
-        success = eina_file_copy(buf, config_edc_path_get(),
-                                 EINA_FILE_COPY_DATA, NULL, NULL);
-     }
-
-   if (!success)
-     {
-        EINA_LOG_ERR("Cannot find file! \"%s\"", buf);
-        return EINA_FALSE;
-     }
-
+   newfile_new(NULL, EINA_TRUE);
    build_edc();
 
    return EINA_TRUE;
diff --git a/src/bin/menu.c b/src/bin/menu.c
index 3fa8f7d..1689f71 100644
--- a/src/bin/menu.c
+++ b/src/bin/menu.c
@@ -37,7 +37,6 @@ static void warning_no_btn_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
                               void *event_info EINA_UNUSED);
 static void new_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                             void *event_info EINA_UNUSED);
-static void edc_reload(menu_data *md, const char *edc_path);
 static void edc_file_save(menu_data *md);
 
 static void
@@ -601,8 +600,7 @@ new_yes_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-
-   edc_reload(md, PROTO_EDC_PATH);
+   newfile_new(md->ed, EINA_FALSE);
    warning_close(md);
    menu_close(md);
 }
@@ -659,15 +657,6 @@ btn_effect_timer_cb(void *data)
 }
 
 static void
-edc_reload(menu_data *md, const char *edc_path)
-{
-   config_edc_path_set(edc_path);
-   edit_new(md->ed);
-   edj_mgr_reload_need_set(EINA_TRUE);
-   config_apply();
-}
-
-static void
 warning_no_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
                   void *event_info EINA_UNUSED)
 {
@@ -682,7 +671,7 @@ new_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
    menu_data *md = data;
 
    edit_save(md->ed);
-   edc_reload(md, PROTO_EDC_PATH);
+   newfile_new(md->ed, EINA_FALSE);
    warning_close(md);
    menu_close(md);
 }
@@ -692,7 +681,7 @@ new_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
            void *event_info EINA_UNUSED)
 {
    menu_data *md = data;
-   menu_edc_new(md);
+   menu_edc_new();
 }
 
 static void
@@ -820,7 +809,7 @@ fileselector_load_done_cb(void *data, Evas_Object *obj, 
void *event_info)
         return;
      }
 
-   edc_reload(md, selected);
+   edit_edc_reload(md->ed, selected);
    fileselector_close(md);
    menu_close(md);
 }
@@ -1023,7 +1012,7 @@ menu_edc_new()
         warning_layout_create(md, new_yes_btn_cb, new_save_btn_cb);
         return EINA_TRUE;
      }
-   edc_reload(md, PROTO_EDC_PATH);
+   newfile_new(md->ed, EINA_FALSE);
    menu_close(md);
 
    return EINA_FALSE;
diff --git a/src/bin/newfile.c b/src/bin/newfile.c
new file mode 100644
index 0000000..9e1995f
--- /dev/null
+++ b/src/bin/newfile.c
@@ -0,0 +1,21 @@
+#include <Elementary.h>
+#include "common.h"
+
+
+void
+newfile_new(edit_data *ed, Eina_Bool init)
+{
+   Eina_Bool success = EINA_TRUE;
+   char buf[PATH_MAX];
+   snprintf(buf, sizeof(buf), "%s/.proto/proto.edc",
+            elm_app_data_dir_get());
+   success = eina_file_copy(buf, config_edc_path_get(),
+                            EINA_FILE_COPY_DATA, NULL, NULL);
+   if (!success)
+     {
+        EINA_LOG_ERR("Cannot find file! \"%s\"", buf);
+        return;
+     }
+
+   if (!init) edit_edc_reload(ed, PROTO_EDC_PATH);
+}
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 15e25aa..573e43e 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -19,4 +19,5 @@ EXTRA_DIST = common.h \
        syntax_helper.h \
        template_code.h \
        tools.h \
+       newfile.h \
        search.h
diff --git a/src/include/common.h b/src/include/common.h
index ce12233..edf3a4a 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -27,5 +27,6 @@ typedef struct indent_s indent_data;
 #include "tools.h"
 #include "base_gui.h"
 #include "search.h"
+#include "newfile.h"
 
 #endif
diff --git a/src/include/edc_editor.h b/src/include/edc_editor.h
index c75a30e..02c3d12 100644
--- a/src/include/edc_editor.h
+++ b/src/include/edc_editor.h
@@ -16,3 +16,4 @@ void edit_template_insert(edit_data *ed);
 void edit_template_part_insert(edit_data *ed, Edje_Part_Type type);
 void edit_part_highlight_toggle(edit_data *ed, Eina_Bool msg);
 void edit_line_delete(edit_data *ed);
+void edit_edc_reload(edit_data *ed, const char *edc_path);
diff --git a/src/include/newfile.h b/src/include/newfile.h
new file mode 100644
index 0000000..730757d
--- /dev/null
+++ b/src/include/newfile.h
@@ -0,0 +1 @@
+void newfile_new(edit_data *ed, Eina_Bool init);

-- 


Reply via email to