Mobile native

[UI Sample] List Sample Overview

The List sample demonstrates how to use double-linked list data structure using EFL list functions. In addition, it shows some ways to append given data to the given linked list.

The sample uses the list functions, such as eina_list_append() for appending the given data to the given linked list, eina_list_nth_list() to get the nth member's list node in a list, and eina_list_append_relative() for inserting the given data into the given linked list after the specified data. It can store data of any type in the form of void pointers.

The following log shows the result of the List sample.

I/USR_TAG ( 6186): tigh
I/USR_TAG ( 6186): adar
I/USR_TAG ( 6186): baltar
I/USR_TAG ( 6186): roslin
I/USR_TAG ( 6186): ----------
I/USR_TAG ( 6186): adama
I/USR_TAG ( 6186): tigh
I/USR_TAG ( 6186): lampkin
I/USR_TAG ( 6186): adar
I/USR_TAG ( 6186): gaeta
I/USR_TAG ( 6186): cain
I/USR_TAG ( 6186): zarek
I/USR_TAG ( 6186): baltar
I/USR_TAG ( 6186): roslin

Figure: Eina list

Eina list

Implementation

The create_base_gui() function creates the window that does not do anything in this sample application. However, it contains list functions and you can see the result in the log output.

Note
When using the eina_list_prepend(), eina_list_append_relative(), or eina_list_append_relative_list() functions, list (the first argument) must be a pointer to the first element of the list.
static void
create_base_gui(appdata_s *ad)
{
   // Window 
   ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
   elm_win_autodel_set(ad->win, EINA_TRUE);

   if (elm_win_wm_rotation_supported_get(ad->win)) 
   {
      int rots[4] = { 0, 90, 180, 270 };
      elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
   }

   evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
   eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);

   // Conformant 
   ad->conform = elm_conformant_add(ad->win);
   elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
   elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
   evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(ad->win, ad->conform);
   evas_object_show(ad->conform);

   // List 
   Eina_List *list = NULL;
   Eina_List *l;  // List that is used as an iterator and points to the current node
   void *list_data;

   // Append the given data to the given linked list
   list = eina_list_append(list, "tigh");
   list = eina_list_append(list, "adar");
   list = eina_list_append(list, "baltar");
   list = eina_list_append(list, "roslin");

   EINA_LIST_FOREACH(list, l, list_data)
      dlog_print(DLOG_INFO, "USR_TAG", "%s", (char*)list_data);
   dlog_print(DLOG_INFO, "USR_TAG", "----------");

   l = eina_list_nth_list(list, 1);  // Get the nth member's list node in a list
   list = eina_list_append_relative_list(list, "cain", l);
   list = eina_list_append_relative(list, "zarek", "cain");
   list = eina_list_prepend(list, "adama");
   list = eina_list_prepend_relative(list, "gaeta", "cain");
   list = eina_list_prepend_relative_list(list, "lampkin", l);

   EINA_LIST_FOREACH(list, l, list_data)
      dlog_print(DLOG_INFO, "USR_TAG", "%s", (char*)list_data);

   eina_list_free(list);


   // Show the window after the base GUI is set up
   evas_object_show(ad->win);
}
Go to top