Update examples to efl_new / efl_add / efl_add_ref

Reviewers: cedric, q66, bu5hm4n

Reviewed By: cedric, bu5hm4n

Differential Revision: https://phab.enlightenment.org/D6058
devs/lauromoura/fix-csharp-life
Xavi Artigas 4 years ago committed by Cedric BAIL
parent 3e23c210cb
commit 33dad0d59c
  1. 2
      apps/c/life/src/life_board.c
  2. 2
      apps/c/life/src/life_main.c
  3. 2
      apps/c/texteditor/src/texteditor_main.c
  4. 12
      reference/c/core/src/core_io.c
  5. 8
      reference/c/core/src/core_loop.c
  6. 10
      reference/c/net/src/net_io.c
  7. 2
      reference/c/ui/src/ui_container.c
  8. 2
      reference/c/ui/src/ui_sizing.c
  9. 5
      reference/c/ui/src/ui_translation.c
  10. 2
      tutorial/c/eo-classes/src/eo_classes_main.c
  11. 4
      tutorial/c/eo-inherit/src/eo_inherit_main.c
  12. 2
      tutorial/c/eo-intro/src/eo_intro_main.c
  13. 6
      tutorial/c/eo-multiinherit/src/eo_multiinherit_main.c
  14. 2
      tutorial/c/eo-refcount/src/eo_refcount_main.c
  15. 2
      tutorial/c/focus/src/focus_main.c
  16. 2
      tutorial/c/hello-gui/src/gui_main.c
  17. 3
      tutorial/c/lifecycle_ui/src/lifecycle_main.c

@ -64,7 +64,7 @@ life_board_init()
void
life_board_run(Efl_Ui_Win *win)
{
_life_timer = efl_add(EFL_LOOP_TIMER_CLASS, NULL,
_life_timer = efl_add(EFL_LOOP_TIMER_CLASS, efl_main_loop_get(),
efl_loop_timer_interval_set(efl_added, 0.1));
efl_event_callback_add(_life_timer, EFL_LOOP_TIMER_EVENT_TICK, _life_tick, win);

@ -60,7 +60,7 @@ _life_win_setup(void)
Evas_Coord w;
Evas_Coord h;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "EFL Life"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

@ -88,7 +88,7 @@ _gui_setup()
{
Eo *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Text Editor"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

@ -21,11 +21,11 @@ _io_write(const char *filename)
Eina_Slice content = EINA_SLICE_STR("### This is a sample string for the file io test ###");
Efl_Io_File *file;
file = efl_add(EFL_IO_FILE_CLASS, NULL,
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
efl_io_file_flags_set(efl_added, O_WRONLY | O_CREAT), // write and create - default is read
efl_io_file_mode_set(efl_added, 0644), // neccessary if we use O_CREAT
efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE)); // recommended
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)
return;
@ -41,7 +41,7 @@ _io_write(const char *filename)
free(string);
}
efl_del(file);
efl_unref(file);
}
static void
@ -50,9 +50,9 @@ _io_read(const char *filename)
EINA_RW_SLICE_DECLARE(content, 1024);
Efl_Io_File *file;
file = efl_add(EFL_IO_FILE_CLASS, NULL,
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE)); // recommended
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)
return;
@ -68,7 +68,7 @@ _io_read(const char *filename)
free(string);
}
efl_del(file);
efl_unref(file);
}
static void

@ -40,7 +40,7 @@ _read_fd_cb(void *data EINA_UNUSED, const Efl_Event *event)
// here we are exiting
if (len <= 0)
{
efl_del(fd_obj);
efl_unref(fd_obj);
unlink(FILENAME);
efl_exit(0);
@ -63,7 +63,7 @@ _write_fd_cb(void *data EINA_UNUSED, const Efl_Event *event)
// and start checking for read availability instead
if (_count >= 5)
{
efl_del(fd_obj);
efl_unref(fd_obj);
_read_fd_create();
return;
@ -81,7 +81,7 @@ _write_fd_create()
FILE *file;
int fd;
fd_obj = efl_add(EFL_LOOP_FD_CLASS, NULL,
fd_obj = efl_new(EFL_LOOP_FD_CLASS,
efl_name_set(efl_added, "Write FD"));
efl_event_callback_add(fd_obj, EFL_LOOP_FD_EVENT_WRITE, _write_fd_cb, NULL);
@ -100,7 +100,7 @@ _read_fd_create()
FILE *file;
int fd;
fd_obj = efl_add(EFL_LOOP_FD_CLASS, NULL,
fd_obj = efl_new(EFL_LOOP_FD_CLASS,
efl_name_set(efl_added, "Read FD"));
efl_event_callback_add(fd_obj, EFL_LOOP_FD_EVENT_READ, _read_fd_cb, NULL);

@ -33,14 +33,12 @@ _quit(int retval)
if (_receiver)
{
efl_io_closer_close(_receiver);
efl_del(efl_io_copier_destination_get(_receiver));
efl_del(_receiver);
}
if (_sender)
{
efl_io_closer_close(_sender);
efl_del(efl_io_copier_source_get(_sender));
efl_del(_sender);
}
@ -158,7 +156,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
* the line_delimiter, then wait for a reply from the server, then
* write another.
*/
send_queue = efl_add(EFL_IO_QUEUE_CLASS, NULL,
send_queue = efl_new(EFL_IO_QUEUE_CLASS,
efl_name_set(efl_added, "send_queue"),
efl_io_queue_limit_set(efl_added, buffer_limit));
if (!send_queue)
@ -179,7 +177,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
* Our example's usage is to peek its data with slice_get() then
* clear().
*/
receive_queue = efl_add(EFL_IO_QUEUE_CLASS, NULL,
receive_queue = efl_new(EFL_IO_QUEUE_CLASS,
efl_name_set(efl_added, "receive_queue"),
efl_io_queue_limit_set(efl_added, buffer_limit),
efl_event_callback_add(efl_added, EFL_IO_QUEUE_EVENT_SLICE_CHANGED, _receiver_data, NULL));
@ -213,6 +211,8 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
efl_io_copier_source_set(efl_added, send_queue),
efl_io_copier_destination_set(efl_added, _dialer),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
/* _sender took an extra ref to send_queue, so we can dispose of ours now */
efl_unref (send_queue);
if (!_sender)
{
fprintf(stderr, "ERROR: could not create Efl_Io_Copier (sender)\n");
@ -226,6 +226,8 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
efl_io_copier_source_set(efl_added, _dialer),
efl_io_copier_destination_set(efl_added, receive_queue),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
/* _receiver took an extra ref to receive_queue, so we can dispose of ours now */
efl_unref (receive_queue);
if (!_receiver)
{
fprintf(stderr, "ERROR: could not create Efl_Io_Copier (receiver)\n");

@ -107,7 +107,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Eo *win;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

@ -27,7 +27,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Efl_Ui_Win *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Size Control"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

@ -33,10 +33,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Efl_Ui_Win *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_translatable_text_set(efl_added, "Translations",
_TEXT_DOMAIN),
efl_text_set(efl_added, "Translations"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
// when the user clicks "close" on a window there is a request to delete

@ -10,7 +10,7 @@ _rect_create()
{
Example_Rectangle *rectangle;
rectangle = efl_add(EXAMPLE_RECTANGLE_CLASS, NULL,
rectangle = efl_new(EXAMPLE_RECTANGLE_CLASS,
efl_name_set(efl_added, "Rectangle"),
example_rectangle_width_set(efl_added, 5),
example_rectangle_height_set(efl_added, 10));

@ -11,7 +11,7 @@ _rectangle_create()
{
Example_Rectangle *rectangle;
rectangle = efl_add(EXAMPLE_RECTANGLE_CLASS, NULL,
rectangle = efl_new(EXAMPLE_RECTANGLE_CLASS,
efl_name_set(efl_added, "Rectangle"),
example_rectangle_width_set(efl_added, 5),
example_rectangle_height_set(efl_added, 10));
@ -24,7 +24,7 @@ _square_create()
{
Example_Square *square;
square = efl_add(EXAMPLE_SQUARE_CLASS, NULL,
square = efl_new(EXAMPLE_SQUARE_CLASS,
efl_name_set(efl_added, "Square"),
example_rectangle_width_set(efl_added, 7));

@ -13,7 +13,7 @@ static void
_obj_create()
{
// First create a root element
_root = efl_add(EFL_MODEL_ITEM_CLASS, NULL,
_root = efl_new(EFL_MODEL_ITEM_CLASS,
efl_name_set(efl_added, "Root"));
// Create the first child element

@ -10,7 +10,7 @@ _circle_create()
{
Example_Circle *circle;
circle = efl_add(EXAMPLE_CIRCLE_CLASS, NULL,
circle = efl_new(EXAMPLE_CIRCLE_CLASS,
efl_name_set(efl_added, "Circle"),
example_circle_radius_set(efl_added, 5));
@ -22,7 +22,7 @@ _rectangle_create()
{
Example_Rectangle *rectangle;
rectangle = efl_add(EXAMPLE_RECTANGLE_CLASS, NULL,
rectangle = efl_new(EXAMPLE_RECTANGLE_CLASS,
efl_name_set(efl_added, "Rectangle"),
example_rectangle_width_set(efl_added, 5),
example_rectangle_height_set(efl_added, 10),
@ -36,7 +36,7 @@ _square_create()
{
Example_Square *square;
square = efl_add(EXAMPLE_SQUARE_CLASS, NULL,
square = efl_new(EXAMPLE_SQUARE_CLASS,
efl_name_set(efl_added, "Square"),
example_rectangle_width_set(efl_added, 7),
example_colored_color_set(efl_added, 64, 64, 64));

@ -52,7 +52,7 @@ static void
_obj_create()
{
// First create a root element
_root = efl_add(EFL_MODEL_ITEM_CLASS, NULL,
_root = efl_new(EFL_MODEL_ITEM_CLASS,
efl_name_set(efl_added, "Root"));
// Add a weak reference so we can keep track of its state
efl_wref_add(_root, &_root_ref);

@ -30,7 +30,7 @@ _gui_setup()
{
Eo *win, *box, *hbox, *about;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_event_callback_add(efl_added,

@ -16,7 +16,7 @@ _gui_setup()
{
Eo *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

@ -16,7 +16,7 @@ _gui_setup()
{
Eo *win;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_name_set(efl_added, "Lifecycle Example"),
efl_text_set(efl_added, "Hello World"),
@ -24,6 +24,7 @@ _gui_setup()
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Quit"),
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
}

Loading…
Cancel
Save