Mobile native

[UI Sample] Job Sample Overview

The Job sample shows how an Ecore_Job can be added, how it can be deleted, and how they always execute in the added order.

First, 2 callback functions are declared, one that prints strings passed to it in the data pointer, and another one that quits the main loop. In the main function, 3 jobs are added using the first callback, and another one is added using the second one.

To see the process, dlogutil in the sdb shell is used. In the sdb shell, enter dlogutil [LOGTAG].

The following log illustrates a screenshot of dlogutil in the sdb shell.

sh-4.1# dlogutil job
arc = 2, optind = 1 ,Kb 0, rotate 4
--------- beginning of /dev/log_system
--------- beginning of /dev/log_main
D/job     ( 5389): Created jobs 1, 2, 3 and quit.
D/job     ( 5389): Deleted job 2. Its data was: "Job 2 started."
D/job     ( 5389): Job 1 started.
D/job     ( 5389): Job 3 started.

Implementation

The create_base_gui() function adds the Ecore_Job using the ecore_job_add() function with the _job_print_cb() and _job_quit_cb() callbacks, and deletes the Ecore_Job using the ecore_job_del() function. To show the job process, the dlog_print() function is used.

#include <Ecore.h>
#include <unistd.h>

static void
_job_print_cb(void *data)
{
   char *str = data;
   dlog_print(DLOG_DEBUG, LOG_TAG, "%s\n", str);
}

static void
_job_quit_cb(void *data EINA_UNUSED)
{
   ecore_main_loop_quit();
}

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);

   // Label
   ad->label = elm_label_add(ad->conform);
   elm_object_text_set(ad->label, "Ecore Job");
   evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_object_content_set(ad->conform, ad->label);
   evas_object_show(ad->label);

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

   // job 
   Ecore_Job *job1, *job2, *job3, *job_quit;
   char *str1 = "Job 1 started.";
   char *str2 = "Job 2 started.";
   char *str3 = "Job 3 started.";

   job1 = ecore_job_add(_job_print_cb, str1);
   job2 = ecore_job_add(_job_print_cb, str2);
   job3 = ecore_job_add(_job_print_cb, str3);
   job_quit = ecore_job_add(_job_quit_cb, NULL);

   dlog_print(DLOG_DEBUG, LOG_TAG, "Created jobs 1, 2, 3 and quit.\n");

   if (job2) 
   {
      char *str;
      str = ecore_job_del(job2);
      job2 = NULL;
      dlog_print(DLOG_DEBUG, LOG_TAG, "Deleted job 2. Its data was: \"%s\"\n", str);
   }
}
Go to top