ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=e3ed8806c3e9782b246063f5cd03f94d60e6f263

commit e3ed8806c3e9782b246063f5cd03f94d60e6f263
Author: Andy Williams <a...@andywilliams.me>
Date:   Tue Jun 2 08:22:36 2015 +0100

    elm_code: add legacy API.
    
    Refactor eo API in line with elm_obj_* elsewhere
---
 .gitignore                                         |  2 +
 Makefile_Eolian_Helper.am                          |  8 ++-
 elm_code/src/bin/elm_code_test_main.c              | 24 ++++-----
 elm_code/src/lib/Elm_Code.h                        |  1 +
 elm_code/src/lib/Makefile.am                       |  5 +-
 elm_code/src/lib/elm_code_diff_widget.c            |  8 +--
 elm_code/src/lib/widget/elm_code_widget.c          | 59 +++++++++++++---------
 elm_code/src/lib/widget/elm_code_widget.eo         |  5 +-
 elm_code/src/lib/widget/elm_code_widget_legacy.h   | 13 +++++
 .../src/lib/widget/elm_code_widget_selection.c     |  8 +--
 elm_code/src/tests/widget/elm_code_test_widget.c   |  6 +--
 .../tests/widget/elm_code_test_widget_selection.c  | 21 +++-----
 src/bin/edi_consolepanel.c                         | 20 +++-----
 src/bin/edi_logpanel.c                             | 10 ++--
 src/bin/editor/edi_editor.c                        | 42 ++++++---------
 src/bin/editor/edi_editor_search.c                 |  8 ++-
 src/bin/mainview/edi_mainview.c                    |  6 +--
 src/bin/screens/edi_settings.c                     |  9 ++--
 src/bin/screens/edi_settings_font.c                | 11 ++--
 19 files changed, 132 insertions(+), 134 deletions(-)

diff --git a/.gitignore b/.gitignore
index 39c72e7..19aea3d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,8 +68,10 @@ po/stamp-po
 /src/tests/check-results.xml
 
 /elm_code/src/lib/*.eo.h
+/elm_code/src/lib/*.eo.legacy.h
 /elm_code/src/lib/*.eo.c
 /elm_code/src/lib/widget/*.eo.h
+/elm_code/src/lib/widget/*.eo.legacy.h
 /elm_code/src/lib/widget/*.eo.c
 
 /elm_code/src/bin/elm_code_test
diff --git a/Makefile_Eolian_Helper.am b/Makefile_Eolian_Helper.am
index 99f9409..168f659 100644
--- a/Makefile_Eolian_Helper.am
+++ b/Makefile_Eolian_Helper.am
@@ -12,15 +12,13 @@ am__v_EOL_0 = @echo "  EOLIAN  " $@;
 
 SUFFIXES = .eo .eo.c .eo.h .eo.legacy.h
 
-#%.eo.c: %.eo ${_EOLIAN_GEN_DEP}
-#      $(AM_V_EOL)$(EOLIAN_GEN) --eo --legacy $(EOLIAN_FLAGS) --gc -o $@ $<
 %.eo.c: %.eo ${_EOLIAN_GEN_DEP}
-       $(AM_V_EOL)$(EOLIAN_GEN) --eo $(EOLIAN_FLAGS) --gc -o $@ $<
+       $(AM_V_EOL)$(EOLIAN_GEN) --eo --legacy $(EOLIAN_FLAGS) --gc -o $@ $<
 
 %.eo.h: %.eo ${_EOLIAN_GEN_DEP}
        $(AM_V_EOL)$(EOLIAN_GEN) --eo $(EOLIAN_FLAGS) --gh -o $@ $<
 
-#%.eo.legacy.h: %.eo ${_EOLIAN_GEN_DEP}
-#      $(AM_V_EOL)$(EOLIAN_GEN) --legacy $(EOLIAN_FLAGS) --gh -o $@ $<
+%.eo.legacy.h: %.eo ${_EOLIAN_GEN_DEP}
+       $(AM_V_EOL)$(EOLIAN_GEN) --legacy $(EOLIAN_FLAGS) --gh -o $@ $<
 
 CLEANFILES += $(BUILT_SOURCES)
diff --git a/elm_code/src/bin/elm_code_test_main.c 
b/elm_code/src/bin/elm_code_test_main.c
index ebca4d4..a7ec071 100644
--- a/elm_code/src/bin/elm_code_test_main.c
+++ b/elm_code/src/bin/elm_code_test_main.c
@@ -69,9 +69,9 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
 
    code = elm_code_create();
    widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+                   elm_obj_code_widget_code_set(code));
    eo_do(widget,
-         elm_code_widget_font_set(NULL, 12),
+         elm_obj_code_widget_font_set(NULL, 12),
          eo_event_callback_add(&ELM_CODE_EVENT_LINE_LOAD_DONE, 
_elm_code_test_line_done_cb, NULL);
          eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, 
_elm_code_test_line_clicked_cb, code));
 
@@ -99,12 +99,12 @@ _elm_code_test_editor_setup(Evas_Object *parent)
 
    code = elm_code_create();
    widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+                   elm_obj_code_widget_code_set(code));
    eo_do(widget,
-         elm_code_widget_font_set(NULL, 14),
-         elm_code_widget_editable_set(EINA_TRUE),
-         elm_code_widget_show_whitespace_set(EINA_TRUE),
-         elm_code_widget_line_numbers_set(EINA_TRUE));
+         elm_obj_code_widget_font_set(NULL, 14),
+         elm_obj_code_widget_editable_set(EINA_TRUE),
+         elm_obj_code_widget_show_whitespace_set(EINA_TRUE),
+         elm_obj_code_widget_line_numbers_set(EINA_TRUE));
 
    _append_line(code->file, "Edit me :)");
    _append_line(code->file, "");
@@ -128,10 +128,10 @@ _elm_code_test_mirror_setup(Elm_Code *code, char 
*font_name, Evas_Object *parent
    Elm_Code_Widget *widget;
 
    widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+                   elm_obj_code_widget_code_set(code));
    eo_do(widget,
-         elm_code_widget_font_set(font_name, 11),
-         elm_code_widget_line_numbers_set(EINA_TRUE));
+         elm_obj_code_widget_font_set(font_name, 11),
+         elm_obj_code_widget_line_numbers_set(EINA_TRUE));
 
    evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -153,7 +153,7 @@ _elm_code_test_diff_inline_setup(Evas_Object *parent)
    elm_code_file_open(code, path);
 
    diff = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                 elm_code_widget_code_set(code));
+                 elm_obj_code_widget_code_set(code));
 
    evas_object_size_hint_weight_set(diff, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(diff, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -209,7 +209,7 @@ _elm_code_test_welcome_mirror_cb(void *data, Evas_Object 
*obj EINA_UNUSED, void
 
    widget = _elm_code_test_editor_setup(screen);
    eo_do(widget,
-         code = elm_code_widget_code_get());
+         code = elm_obj_code_widget_code_get());
    elm_box_pack_end(screen, widget);
 
    elm_box_pack_end(screen, _elm_code_test_mirror_setup(code, 
"Mono:style=Oblique", screen));
diff --git a/elm_code/src/lib/Elm_Code.h b/elm_code/src/lib/Elm_Code.h
index 83d8d27..9d14b40 100644
--- a/elm_code/src/lib/Elm_Code.h
+++ b/elm_code/src/lib/Elm_Code.h
@@ -39,6 +39,7 @@
 #include "elm_code_file.h"
 #include "elm_code_parse.h"
 #include "widget/elm_code_widget.eo.h"
+#include "widget/elm_code_widget_legacy.h"
 #include "widget/elm_code_widget_selection.h"
 #include "elm_code_diff_widget.h"
 
diff --git a/elm_code/src/lib/Makefile.am b/elm_code/src/lib/Makefile.am
index b9f7b04..087f863 100644
--- a/elm_code/src/lib/Makefile.am
+++ b/elm_code/src/lib/Makefile.am
@@ -24,6 +24,7 @@ elm_code_text.h \
 elm_code_file.h \
 elm_code_parse.h \
 widget/elm_code_widget.eo.h \
+widget/elm_code_widget.eo.legacy.h \
 widget/elm_code_widget_selection.h \
 elm_code_diff_widget.h \
 Elm_Code.h
@@ -51,10 +52,12 @@ widget/elm_code_widget.eo
 
 elm_code_eolian_c = $(elm_code_eolian_files:%.eo=%.eo.c)
 elm_code_eolian_h = $(elm_code_eolian_files:%.eo=%.eo.h)
+elm_code_eolian_legacy_h =  $(elm_code_eolian_files:%.eo=%.eo.legacy.h)
 
 BUILT_SOURCES = \
         $(elm_code_eolian_c) \
-        $(elm_code_eolian_h)
+        $(elm_code_eolian_h) \
+        $(elm_code_eolian_legacy_h)
 
 elmcodeeolianfilesdir = $(datadir)/eolian/include/elm_code-@VMAJ@
 elmcodeeolianfiles_DATA = $(elm_code_eolian_files)
diff --git a/elm_code/src/lib/elm_code_diff_widget.c 
b/elm_code/src/lib/elm_code_diff_widget.c
index e07b9cb..a16ecbf 100644
--- a/elm_code/src/lib/elm_code_diff_widget.c
+++ b/elm_code/src/lib/elm_code_diff_widget.c
@@ -96,7 +96,7 @@ elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
    wcode1 = elm_code_create();
    elm_code_parser_standard_add(wcode1, ELM_CODE_PARSER_STANDARD_DIFF);
    widget_left = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                        elm_code_widget_code_set(wcode1));
+                        elm_obj_code_widget_code_set(wcode1));
 
    evas_object_size_hint_weight_set(widget_left, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget_left, EVAS_HINT_FILL, 
EVAS_HINT_FILL);
@@ -108,7 +108,7 @@ elm_code_diff_widget_add(Evas_Object *parent, Elm_Code 
*code)
    wcode2 = elm_code_create();
    elm_code_parser_standard_add(wcode2, ELM_CODE_PARSER_STANDARD_DIFF);
    widget_right = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                         elm_code_widget_code_set(wcode2));
+                         elm_obj_code_widget_code_set(wcode2));
 
    evas_object_size_hint_weight_set(widget_right, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget_right, EVAS_HINT_FILL, 
EVAS_HINT_FILL);
@@ -126,8 +126,8 @@ elm_code_diff_widget_font_set(Evas_Object *widget, const 
char *name, int size)
    Elm_Code_Widget *child;
 
    child = (Elm_Code_Widget *) evas_object_data_get(widget, 
_ELM_CODE_DIFF_WIDGET_LEFT);
-   eo_do(child, elm_code_widget_font_set(name, size));
+   eo_do(child, elm_obj_code_widget_font_set(name, size));
    child = (Elm_Code_Widget *) evas_object_data_get(widget, 
_ELM_CODE_DIFF_WIDGET_RIGHT);
-   eo_do(child, elm_code_widget_font_set(name, size));
+   eo_do(child, elm_obj_code_widget_font_set(name, size));
 }
 
diff --git a/elm_code/src/lib/widget/elm_code_widget.c 
b/elm_code/src/lib/widget/elm_code_widget.c
index bf63c35..c231d44 100644
--- a/elm_code/src/lib/widget/elm_code_widget.c
+++ b/elm_code/src/lib/widget/elm_code_widget.c
@@ -6,6 +6,8 @@
 #include "elm_code_private.h"
 #include "elm_code_widget_private.h"
 
+#define MY_CLASS ELM_CODE_WIDGET_CLASS
+
 typedef enum {
    ELM_CODE_WIDGET_COLOR_GUTTER_BG = ELM_CODE_TOKEN_TYPE_COUNT,
    ELM_CODE_WIDGET_COLOR_GUTTER_FG,
@@ -45,6 +47,15 @@ Eina_Unicode status_icons[] = {
      } \
 } while (0)
 
+EAPI Evas_Object *
+elm_code_widget_add(Evas_Object *parent, Elm_Code *code)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+   Evas_Object *obj = eo_add(MY_CLASS, parent,
+                             elm_obj_code_widget_code_set(code));
+   return obj;
+}
+
 EOLIAN static Eo *
 _elm_code_widget_eo_base_constructor(Eo *obj, Elm_Code_Widget_Data *pd)
 {
@@ -101,7 +112,7 @@ _elm_code_widget_resize(Elm_Code_Widget *widget)
    Elm_Code_Widget_Data *pd;
 
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
 
    if (!pd->code)
      return;
@@ -172,7 +183,7 @@ _elm_code_widget_fill_line_tokens(Elm_Code_Widget *widget, 
Evas_Textgrid_Cell *c
    unsigned int token_start_col, token_end_col;
 
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
-   eo_do(widget, offset = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, offset = elm_obj_code_widget_text_left_gutter_width_get());
    start = offset;
    length = elm_code_line_text_column_width(line, pd->tabstop) + offset;
 
@@ -205,7 +216,7 @@ _elm_code_widget_fill_gutter(Elm_Code_Widget *widget, 
Evas_Textgrid_Cell *cells,
    Elm_Code_Widget_Data *pd;
 
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
 
    evas_object_textgrid_size_get(pd->grid, &w, NULL);
 
@@ -320,7 +331,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, 
Elm_Code_Line *line)
    Elm_Code_Widget_Data *pd;
 
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
 
    evas_object_textgrid_size_get(pd->grid, &w, NULL);
    cells = evas_object_textgrid_cellrow_get(pd->grid, line->number - 1);
@@ -373,7 +384,7 @@ _elm_code_widget_empty_line(Elm_Code_Widget *widget, 
unsigned int number)
    Elm_Code_Widget_Data *pd;
 
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
 
    evas_object_textgrid_size_get(pd->grid, &w, NULL);
    cells = evas_object_textgrid_cellrow_get(pd->grid, number - 1);
@@ -424,7 +435,7 @@ _elm_code_widget_line_cb(void *data, Eo *obj EINA_UNUSED,
    line = (Elm_Code_Line *)event_info;
    widget = (Elm_Code_Widget *)data;
 
-   eo_do(widget, visible = elm_code_widget_line_visible_get(line));
+   eo_do(widget, visible = elm_obj_code_widget_line_visible_get(line));
    if (!visible)
      return EO_CALLBACK_CONTINUE;
 
@@ -534,7 +545,7 @@ _elm_code_widget_cursor_ensure_visible(Elm_Code_Widget 
*widget)
    elm_scroller_region_get(pd->scroller, &viewx, &viewy, &vieww, &viewh);
    evas_object_textgrid_cell_size_get(pd->grid, &cellw, &cellh);
 
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
    curx = (pd->cursor_col + gutter - 1) * cellw;
    cury = (pd->cursor_line - 1) * cellh;
 
@@ -588,7 +599,7 @@ 
_elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_W
    y = y + sy - oy;
 
    evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch);
-   eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get());
+   eo_do(widget, gutter = elm_obj_code_widget_text_left_gutter_width_get());
    number = ((double) y / ch) + 1;
    if (col)
      *col = ((double) x / cw) - gutter + 1;
@@ -866,7 +877,7 @@ 
_elm_code_widget_cursor_move_page_height_get(Elm_Code_Widget *widget)
 {
    unsigned int lines;
 
-   eo_do(widget, lines = elm_code_widget_lines_visible_get());
+   eo_do(widget, lines = elm_obj_code_widget_lines_visible_get());
    return lines * 0.85;
 }
 
@@ -949,8 +960,8 @@ _elm_code_widget_text_at_cursor_insert(Elm_Code_Widget 
*widget, const char *text
 
    _elm_code_widget_delete_selection(widget);
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
    line = elm_code_file_line_get(code->file, row);
 
    position = elm_code_line_text_position_for_column_get(line, col - 1, 
pd->tabstop);
@@ -959,7 +970,7 @@ _elm_code_widget_text_at_cursor_insert(Elm_Code_Widget 
*widget, const char *text
                elm_code_line_text_column_width_to_position(line, position, 
pd->tabstop);
 
    eo_do(widget,
-         elm_code_widget_cursor_position_set(col + col_width, row),
+         elm_obj_code_widget_cursor_position_set(col + col_width, row),
 // TODO construct and pass a change object
          eo_event_callback_call(ELM_CODE_WIDGET_EVENT_CHANGED_USER, NULL));
 }
@@ -975,15 +986,15 @@ _elm_code_widget_newline(Elm_Code_Widget *widget)
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
    _elm_code_widget_delete_selection(widget);
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
    line = elm_code_file_line_get(code->file, row);
 
    position = elm_code_line_text_position_for_column_get(line, col - 1, 
pd->tabstop);
    elm_code_line_split_at(line, position);
 
    eo_do(widget,
-         elm_code_widget_cursor_position_set(1, row + 1),
+         elm_obj_code_widget_cursor_position_set(1, row + 1),
 // TODO construct and pass a change object
          eo_event_callback_call(ELM_CODE_WIDGET_EVENT_CHANGED_USER, NULL));
 }
@@ -1001,8 +1012,8 @@ _elm_code_widget_backspaceline(Elm_Code_Widget *widget, 
Eina_Bool nextline)
    unsigned int length1, length2;
 
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
    line = elm_code_file_line_get(code->file, row);
 
    if (nextline)
@@ -1033,7 +1044,7 @@ _elm_code_widget_backspaceline(Elm_Code_Widget *widget, 
Eina_Bool nextline)
         position = elm_code_line_text_column_width_to_position(line, length1, 
pd->tabstop);
 
         eo_do(widget,
-              elm_code_widget_cursor_position_set(position + 1, row - 1));
+              elm_obj_code_widget_cursor_position_set(position + 1, row - 1));
      }
 // TODO construct and pass a change object
    eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_CHANGED_USER, 
NULL));
@@ -1051,8 +1062,8 @@ _elm_code_widget_backspace(Elm_Code_Widget *widget)
      return;
 
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
    pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
 
    if (col <= 1)
@@ -1073,7 +1084,7 @@ _elm_code_widget_backspace(Elm_Code_Widget *widget)
 
    elm_code_line_text_remove(line, position, char_width?char_width:1);
    eo_do(widget,
-         elm_code_widget_cursor_position_set(start_col + 1, row));
+         elm_obj_code_widget_cursor_position_set(start_col + 1, row));
 
 // TODO construct and pass a change object
    eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_CHANGED_USER, 
NULL));
@@ -1093,8 +1104,8 @@ _elm_code_widget_delete(Elm_Code_Widget *widget)
      return;
 
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
    line = elm_code_file_line_get(code->file, row);
    if (col > elm_code_line_text_column_width(line, pd->tabstop))
      {
@@ -1112,7 +1123,7 @@ _elm_code_widget_delete(Elm_Code_Widget *widget)
 
    elm_code_line_text_remove(line, position, char_width?char_width:1);
    eo_do(widget,
-         elm_code_widget_cursor_position_set(start_col + 1, row),
+         elm_obj_code_widget_cursor_position_set(start_col + 1, row),
 // TODO construct and pass a change object
          eo_event_callback_call(ELM_CODE_WIDGET_EVENT_CHANGED_USER, NULL));
 }
diff --git a/elm_code/src/lib/widget/elm_code_widget.eo 
b/elm_code/src/lib/widget/elm_code_widget.eo
index 61e8b87..cd8be42 100644
--- a/elm_code/src/lib/widget/elm_code_widget.eo
+++ b/elm_code/src/lib/widget/elm_code_widget.eo
@@ -1,6 +1,7 @@
-class Elm_Code_Widget (Elm.Layout, Elm_Interface_Atspi_Text)
+class Elm.Code_Widget (Elm.Layout, Elm_Interface_Atspi_Text)
 {
-   eo_prefix: elm_code_widget;
+   eo_prefix: elm_obj_code_widget;
+   legacy_prefix: elm_code_widget;
    methods {
       @property code {
          set {
diff --git a/elm_code/src/lib/widget/elm_code_widget_legacy.h 
b/elm_code/src/lib/widget/elm_code_widget_legacy.h
new file mode 100644
index 0000000..5110e30
--- /dev/null
+++ b/elm_code/src/lib/widget/elm_code_widget_legacy.h
@@ -0,0 +1,13 @@
+/**
+ * @brief Add a new elm_code widget to the parent
+ *
+ * @param parent The parent object
+ * @return The new object or NULL if it cannot be created
+ *
+ * @see elm_code_widget_code_set
+ *
+ * @ingroup Data
+ */
+EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code);
+
+#include "elm_code_widget.eo.legacy.h"
diff --git a/elm_code/src/lib/widget/elm_code_widget_selection.c 
b/elm_code/src/lib/widget/elm_code_widget_selection.c
index 88642de..a410e27 100644
--- a/elm_code/src/lib/widget/elm_code_widget_selection.c
+++ b/elm_code/src/lib/widget/elm_code_widget_selection.c
@@ -62,7 +62,7 @@ elm_code_widget_selection_start(Evas_Object *widget,
    pd->selection->start_col = col;
    eo_do(widget,
          eo_event_callback_call(ELM_CODE_WIDGET_EVENT_SELECTION_CHANGED, 
widget),
-         elm_code_widget_cursor_position_set(col, line));
+         elm_obj_code_widget_cursor_position_set(col, line));
 }
 
 EAPI void
@@ -311,7 +311,7 @@ _selection_paste_single(Elm_Code_Widget *widget, 
Elm_Code_Widget_Data *pd, Elm_C
 
    newcol = elm_code_line_text_column_width_to_position(line, position + len, 
pd->tabstop);
    eo_do(widget,
-         elm_code_widget_cursor_position_set(newcol + 1, row));
+         elm_obj_code_widget_cursor_position_set(newcol + 1, row));
 }
 
 static void
@@ -364,8 +364,8 @@ _selection_paste_cb(void *data, Evas_Object *obj 
EINA_UNUSED, Elm_Selection_Data
      return EINA_TRUE;
 
    eo_do(widget,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&col, &row));
+         code = elm_obj_code_widget_code_get(),
+         elm_obj_code_widget_cursor_position_get(&col, &row));
 
    if (elm_code_text_newlinenpos(ev->data, ev->len, NULL) == 
ELM_CODE_TEXT_NOT_FOUND)
      _selection_paste_single(widget, pd, code, col, row, ev->data, ev->len - 
1);
diff --git a/elm_code/src/tests/widget/elm_code_test_widget.c 
b/elm_code/src/tests/widget/elm_code_test_widget.c
index b2f3d18..cd10319 100644
--- a/elm_code/src/tests/widget/elm_code_test_widget.c
+++ b/elm_code/src/tests/widget/elm_code_test_widget.c
@@ -28,8 +28,7 @@ START_TEST (elm_code_widget_token_render_simple_test)
    code = elm_code_create();
 
    win = elm_win_add(NULL, "code", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    file = code->file;
    elm_code_file_line_append(file, "some \"test content\", 45", 23, NULL);
@@ -62,8 +61,7 @@ START_TEST (elm_code_widget_construct)
    code = elm_code_create();
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    ck_assert(!!widget);
    elm_code_free(code);
diff --git a/elm_code/src/tests/widget/elm_code_test_widget_selection.c 
b/elm_code/src/tests/widget/elm_code_test_widget_selection.c
index 3463c45..bb52747 100644
--- a/elm_code/src/tests/widget/elm_code_test_widget_selection.c
+++ b/elm_code/src/tests/widget/elm_code_test_widget_selection.c
@@ -19,8 +19,7 @@ START_TEST (elm_code_test_widget_selection_set)
    elm_code_file_line_append(file, "test", 4, NULL);
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    elm_code_widget_selection_start(widget, 1, 2);
    elm_code_widget_selection_end(widget, 1, 3);
@@ -45,8 +44,7 @@ START_TEST (elm_code_test_widget_selection_text_get)
    elm_code_file_line_append(file, "test", 4, NULL);
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    ck_assert_str_eq("", elm_code_widget_selection_text_get(widget));
 
@@ -80,8 +78,7 @@ START_TEST (elm_code_test_widget_selection_text_get_twoline)
    elm_code_file_line_append(file, "test", 4, NULL);
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    elm_code_widget_selection_start(widget, 1, 3);
    elm_code_widget_selection_end(widget, 2, 2);
@@ -111,8 +108,7 @@ START_TEST 
(elm_code_test_widget_selection_text_get_multiline)
    elm_code_file_line_append(file, "test", 4, NULL);
 
    win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
 
    elm_code_widget_selection_start(widget, 1, 3);
    elm_code_widget_selection_end(widget, 3, 2);
@@ -141,8 +137,7 @@ START_TEST (elm_code_test_widget_selection_delete)
    elm_code_file_line_append(file, "text", 4, NULL);
 
    win = elm_win_add(NULL, "code", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
    line = elm_code_file_line_get(file, 1);
    text = elm_code_line_text_get(line, NULL);
    ck_assert_str_eq("text", text);
@@ -176,8 +171,7 @@ START_TEST (elm_code_test_widget_selection_delete_twoline)
    elm_code_file_line_append(file, "TEXT", 4, NULL);
 
    win = elm_win_add(NULL, "code", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
    line = elm_code_file_line_get(file, 1);
    text = elm_code_line_text_get(line, NULL);
    ck_assert_str_eq("text", text);
@@ -214,8 +208,7 @@ START_TEST (elm_code_test_widget_selection_delete_multiline)
    elm_code_file_line_append(file, "TEXT", 4, NULL);
 
    win = elm_win_add(NULL, "code", ELM_WIN_BASIC);
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, win,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(win, code);
    line = elm_code_file_line_get(file, 1);
    text = elm_code_line_text_get(line, NULL);
    ck_assert_str_eq("text", text);
diff --git a/src/bin/edi_consolepanel.c b/src/bin/edi_consolepanel.c
index 2da1a3b..64c9b8a 100644
--- a/src/bin/edi_consolepanel.c
+++ b/src/bin/edi_consolepanel.c
@@ -318,14 +318,12 @@ _edi_consolepanel_config_changed(void *data EINA_UNUSED, 
int type EINA_UNUSED, v
 
    EINA_LIST_FOREACH(_edi_console_code->widgets, item, widget)
      {
-        eo_do(widget,
-              elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size));
+        elm_code_widget_font_set(widget, _edi_project_config->font.name, 
_edi_project_config->font.size);
      }
 
    EINA_LIST_FOREACH(_edi_test_code->widgets, item, widget)
      {
-        eo_do(widget,
-              elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size));
+        elm_code_widget_font_set(widget, _edi_project_config->font.name, 
_edi_project_config->font.size);
      }
 
    return ECORE_CALLBACK_RENEW;
@@ -339,11 +337,10 @@ void edi_consolepanel_add(Evas_Object *parent)
    code = elm_code_create();
    _edi_console_code = code;
 
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(parent, code);
    eo_do(widget,
-         elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
-         elm_code_widget_gravity_set(0.0, 1.0),
+         elm_obj_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
+         elm_obj_code_widget_gravity_set(0.0, 1.0),
          eo_event_callback_add(&ELM_CODE_EVENT_LINE_LOAD_DONE, 
_edi_consolepanel_line_cb, NULL),
          eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, 
_edi_consolepanel_clicked_cb, code));
 
@@ -366,11 +363,10 @@ void edi_testpanel_add(Evas_Object *parent)
    code = elm_code_create();
    _edi_test_code = code;
 
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(parent, code);
    eo_do(widget,
-         elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
-         elm_code_widget_gravity_set(0.0, 1.0),
+         elm_obj_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
+         elm_obj_code_widget_gravity_set(0.0, 1.0),
          eo_event_callback_add(&ELM_CODE_EVENT_LINE_LOAD_DONE, 
_edi_testpanel_line_cb, NULL),
          eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, 
_edi_consolepanel_clicked_cb, code));
 
diff --git a/src/bin/edi_logpanel.c b/src/bin/edi_logpanel.c
index d4625a8..24f3fd8 100644
--- a/src/bin/edi_logpanel.c
+++ b/src/bin/edi_logpanel.c
@@ -49,8 +49,7 @@ _edi_logpanel_line_cb(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED,
 static Eina_Bool
 _edi_logpanel_config_changed(void *data EINA_UNUSED, int type EINA_UNUSED, 
void *event EINA_UNUSED)
 {
-   eo_do(_info_widget,
-         elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size));
+   elm_code_widget_font_set(_info_widget, _edi_project_config->font.name, 
_edi_project_config->font.size);
 
    return ECORE_CALLBACK_RENEW;
 }
@@ -61,11 +60,10 @@ void edi_logpanel_add(Evas_Object *parent)
    Elm_Code *code;
 
    code = elm_code_create();
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(parent, code);
    eo_do(widget,
-         elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
-         elm_code_widget_gravity_set(0.0, 1.0),
+         elm_obj_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
+         elm_obj_code_widget_gravity_set(0.0, 1.0),
          eo_event_callback_add(&ELM_CODE_EVENT_LINE_LOAD_DONE, 
_edi_logpanel_line_cb, NULL));
    evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index 0e974a4..f787c2e 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -196,8 +196,7 @@ _edit_cursor_moved(void *data EINA_UNUSED, Evas_Object 
*obj, void *event_info EI
    unsigned int col;
 
    widget = (Elm_Code_Widget *)obj;
-   eo_do(widget,
-         elm_code_widget_cursor_position_get(&col, &line));
+   elm_code_widget_cursor_position_get(widget, &col, &line);
 
    snprintf(buf, sizeof(buf), "Line:%d, Column:%d", line, col);
    elm_object_text_set((Evas_Object *)data, buf);
@@ -223,8 +222,7 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor 
*editor, Edi_Mainview_I
    elm_object_disabled_set(mime, EINA_TRUE);
 
    lines = elm_label_add(panel);
-   eo_do(editor->entry,
-         code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
    if (elm_code_file_line_ending_get(code->file) == 
ELM_CODE_FILE_LINE_ENDING_WINDOWS)
      elm_object_text_set(lines, "WIN");
    else
@@ -254,8 +252,7 @@ _edi_range_color_set(Edi_Editor *editor, Edi_Range range, 
Elm_Code_Token_Type ty
    Elm_Code_Line *line, *extra_line;
    unsigned int number;
 
-   eo_do(editor->entry,
-         code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
    line = elm_code_file_line_get(code->file, range.start.line);
 
    ecore_thread_main_loop_begin();
@@ -263,13 +260,11 @@ _edi_range_color_set(Edi_Editor *editor, Edi_Range range, 
Elm_Code_Token_Type ty
    elm_code_line_token_add(line, range.start.col, range.end.col - 1,
                            range.end.line - range.start.line + 1, type);
 
-   eo_do(editor->entry,
-         elm_code_widget_line_refresh(line));
+   elm_code_widget_line_refresh(editor->entry, line);
    for (number = line->number + 1; number <= range.end.line; number++)
      {
         extra_line = elm_code_file_line_get(code->file, number);
-        eo_do(editor->entry,
-              elm_code_widget_line_refresh(extra_line));
+        elm_code_widget_line_refresh(editor->entry, extra_line);
      }
 
    ecore_thread_main_loop_end();
@@ -282,8 +277,7 @@ _edi_line_status_set(Edi_Editor *editor, unsigned int 
number, Elm_Code_Status_Ty
    Elm_Code *code;
    Elm_Code_Line *line;
 
-   eo_do(editor->entry,
-         code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
    line = elm_code_file_line_get(code->file, number);
    if (!line)
      {
@@ -298,8 +292,7 @@ _edi_line_status_set(Edi_Editor *editor, unsigned int 
number, Elm_Code_Status_Ty
    if (text)
      elm_code_line_status_text_set(line, text);
 
-   eo_do(editor->entry,
-         elm_code_widget_line_refresh(line));
+   elm_code_widget_line_refresh(editor->entry, line);
 
    ecore_thread_main_loop_end();
 }
@@ -440,7 +433,7 @@ _clang_load_errors(const char *path EINA_UNUSED, Edi_Editor 
*editor)
    unsigned n = clang_getNumDiagnostics(editor->tx_unit);
    unsigned i = 0;
 
-   eo_do(editor->entry, code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
 
    for(i = 0, n = clang_getNumDiagnostics(editor->tx_unit); i != n; ++i)
      {
@@ -496,8 +489,7 @@ _edi_clang_setup(void *data, Ecore_Thread *thread 
EINA_UNUSED)
    unsigned int clang_argc;
 
    editor = (Edi_Editor *)data;
-   eo_do(editor->entry,
-         code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
    path = elm_code_file_path_get(code->file);
 
    /* Clang */
@@ -573,10 +565,10 @@ _edi_editor_config_changed(void *data, int type 
EINA_UNUSED, void *event EINA_UN
 
    widget = (Elm_Code_Widget *) data;
    eo_do(widget,
-         elm_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
-         
elm_code_widget_show_whitespace_set(_edi_project_config->gui.show_whitespace),
-         
elm_code_widget_line_width_marker_set(_edi_project_config->gui.width_marker),
-         elm_code_widget_tabstop_set(_edi_project_config->gui.tabstop));
+         elm_obj_code_widget_font_set(_edi_project_config->font.name, 
_edi_project_config->font.size),
+         
elm_obj_code_widget_show_whitespace_set(_edi_project_config->gui.show_whitespace),
+         
elm_obj_code_widget_line_width_marker_set(_edi_project_config->gui.width_marker),
+         elm_obj_code_widget_tabstop_set(_edi_project_config->gui.tabstop));
 
    return ECORE_CALLBACK_RENEW;
 }
@@ -616,11 +608,9 @@ edi_editor_add(Evas_Object *parent, Edi_Mainview_Item 
*item)
    evas_object_show(statusbar);
 
    code = elm_code_create();
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, vbox,
-         elm_code_widget_code_set(code));
-   eo_do(widget,
-         elm_code_widget_editable_set(EINA_TRUE),
-         elm_code_widget_line_numbers_set(EINA_TRUE));
+   widget = elm_code_widget_add(vbox, code);
+   elm_code_widget_editable_set(widget, EINA_TRUE);
+   elm_code_widget_line_numbers_set(widget, EINA_TRUE);
    _edi_editor_config_changed(widget, 0, NULL);
 
    editor = calloc(1, sizeof(*editor));
diff --git a/src/bin/editor/edi_editor_search.c 
b/src/bin/editor/edi_editor_search.c
index 76479b7..6bb858a 100644
--- a/src/bin/editor/edi_editor_search.c
+++ b/src/bin/editor/edi_editor_search.c
@@ -54,9 +54,8 @@ _edi_search_in_entry(Evas_Object *entry, Edi_Editor_Search 
*search)
         return EINA_FALSE;
      }
 
-   eo_do(entry,
-         code = elm_code_widget_code_get(),
-         elm_code_widget_cursor_position_get(&pos_col, &pos_line));
+   code = elm_code_widget_code_get(entry);
+   elm_code_widget_cursor_position_get(entry, &pos_col, &pos_line);
    if (search->current_search_line == pos_line ||
        search->current_search_col == pos_col)
      {
@@ -142,8 +141,7 @@ _edi_replace_in_entry(void *data, Edi_Editor_Search *search)
      {
         if (search->current_search_line)
           {
-             eo_do(editor->entry,
-                   code = elm_code_widget_code_get());
+             code = elm_code_widget_code_get(editor->entry);
 
              elm_code_widget_selection_delete(editor->entry);
              replace = elm_object_text_get(search->replace_entry);
diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c
index 42a619f..3a98651 100644
--- a/src/bin/mainview/edi_mainview.c
+++ b/src/bin/mainview/edi_mainview.c
@@ -481,8 +481,7 @@ edi_mainview_save()
    if (!editor)
      return;
 
-   eo_do(editor->entry,
-         code = elm_code_widget_code_get());
+   code = elm_code_widget_code_get(editor->entry);
    elm_code_file_save(code->file);
 }
 
@@ -589,8 +588,7 @@ edi_mainview_goto(int line)
    if (!content || !editor || line <= 0)
      return;
 
-   eo_do(editor->entry,
-         elm_code_widget_cursor_position_set(1, line));
+   elm_code_widget_cursor_position_set(editor->entry, 1, line);
    elm_object_focus_set(editor->entry, EINA_TRUE);
 }
 
diff --git a/src/bin/screens/edi_settings.c b/src/bin/screens/edi_settings.c
index a8c3cb7..322e851 100644
--- a/src/bin/screens/edi_settings.c
+++ b/src/bin/screens/edi_settings.c
@@ -118,12 +118,11 @@ _edi_settings_font_preview_add(Evas_Object *parent, const 
char *font_name, int f
    code = elm_code_create();
    elm_code_file_line_append(code->file, FONT_PREVIEW, 35, NULL);
 
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(parent, code);
    eo_do(widget,
-         elm_code_widget_font_set(font_name, font_size),
-         elm_code_widget_line_numbers_set(EINA_TRUE),
-         elm_code_widget_editable_set(EINA_FALSE));
+         elm_obj_code_widget_font_set(font_name, font_size),
+         elm_obj_code_widget_line_numbers_set(EINA_TRUE),
+         elm_obj_code_widget_editable_set(EINA_FALSE));
    evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(widget);
diff --git a/src/bin/screens/edi_settings_font.c 
b/src/bin/screens/edi_settings_font.c
index a7a4331..23b8eb9 100644
--- a/src/bin/screens/edi_settings_font.c
+++ b/src/bin/screens/edi_settings_font.c
@@ -37,13 +37,12 @@ _edi_settings_font_preview_add(Evas_Object *parent, const 
char *font_name, int f
    code = elm_code_create();
    elm_code_file_line_append(code->file, FONT_PREVIEW, 35, NULL);
 
-   widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
-                   elm_code_widget_code_set(code));
+   widget = elm_code_widget_add(parent, code);
    eo_do(widget,
-         elm_code_widget_font_set(font_name, font_size),
-         elm_code_widget_line_numbers_set(EINA_TRUE),
-         elm_code_widget_editable_set(EINA_FALSE),
-         elm_code_widget_policy_set(ELM_SCROLLER_POLICY_OFF, 
ELM_SCROLLER_POLICY_OFF));
+         elm_obj_code_widget_font_set(font_name, font_size),
+         elm_obj_code_widget_line_numbers_set(EINA_TRUE),
+         elm_obj_code_widget_editable_set(EINA_FALSE),
+         elm_obj_code_widget_policy_set(ELM_SCROLLER_POLICY_OFF, 
ELM_SCROLLER_POLICY_OFF));
    evas_object_size_hint_weight_set(widget, 0.5, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(widget);

-- 


Reply via email to