Languages

Menu
Sites
Language
Native app: Hello World Error

Hello 

To start with Native App development I'm following the Hello World tutorial.

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/ui_tutorial/helloworld_tutorial.htm

I'm facing following errors. 

../src/basicui1.c:121:55: error: use of undeclared identifier 'clicked_cb'
           evas_object_smart_callback_add(button, "clicked", clicked_cb, NULL);
                                                             ^
../src/basicui1.c:150:28: error: expected ')'
clicked_cb(void *user_data __UNUSED__ , Evas_Object *obj __UNUSED__ , void *event_info __UNUSED__)
                           ^
../src/basicui1.c:150:11: note: to match this '('
clicked_cb(void *user_data __UNUSED__ , Evas_Object *obj __UNUSED__ , void *event_info __UNUSED__)
          ^
2 errors generated.
src/subdir.mk:18: recipe for target 'src/basicui1.o' failed
make: *** [src/basicui1.o] Error 1

 

Any idea, what I'm missing? 

View Selected Answer

Responses

2 Replies
Mark as answer
Sanjeev BA

Reordering and fixing compile issues. Here's a version that can be copy pasted.

 

#include <tizen.h>
#include "basicui1.h"

typedef struct appdata {
   // All graphical objects here are pointers to value of type Evas_Object.
   Evas_Object *win;
   Evas_Object *conformant;
   Evas_Object *naviframe;
} appdata_s;

static void clicked_cb(void *user_data , Evas_Object *obj , void *event_info )
{
   elm_exit();
}

static void
create_gui(appdata_s *ad)
{
   // Create the window
   ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
   elm_win_conformant_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", NULL, NULL);
   ad->conformant = elm_conformant_add(ad->win);
   evas_object_size_hint_weight_set(ad->conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

   elm_win_resize_object_add(ad->win, ad->conformant);
   evas_object_show(ad->conformant);
   ad->naviframe = elm_naviframe_add(ad->conformant);
   elm_object_content_set(ad->conformant, ad->naviframe);
   evas_object_show(ad->conformant);
   Evas_Object *box = elm_box_add(ad->naviframe);
   elm_box_horizontal_set(box, EINA_FALSE);
   evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
   elm_naviframe_item_push(ad->naviframe, "Hello World", NULL, NULL, box, NULL);
   evas_object_show(box);
   Evas_Object *label = elm_label_add(box);
   evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.5);
   elm_object_text_set(label,
         "<align=center>Hello World!</align><br>"
         "<br>"
         "<wrap=word>Clicking on the button below will close the application.</wrap>");
   elm_box_pack_end(box, label);
   evas_object_show(label);
   Evas_Object *button = elm_button_add(box);
   evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 1);
   elm_object_text_set(button, "Close!");
   evas_object_smart_callback_add(button, "clicked", clicked_cb, NULL);
   elm_box_pack_end(box, button);
   evas_object_show(button);
   evas_object_show(ad->win);
}


static bool
app_create(void *data)
{
   appdata_s *ad = data;
   create_gui(ad);
   return true;
}

int
main(int argc, char *argv[])
{
   appdata_s *ad = {0,};
   int ret = 0;
   ui_app_lifecycle_callback_s event_callback = {0,};
   app_event_handler_h handlers[5] = {NULL, };

   event_callback.create = app_create;
   event_callback.terminate = NULL;
   event_callback.pause = NULL;
   event_callback.resume = NULL;
   event_callback.app_control = NULL;

   ret = ui_app_main(argc, argv, &event_callback, &ad);
   if (ret != APP_ERROR_NONE)
   {
      LOGE("ui_app_main() is failed. err = %d", ret);
   }
   return ret;
}

 

Also make sure you create a security profile before launching the app.

 

Daniel Juyung Seo

Thanks Sanjeev.

Yes clicked_cb() function was used before it is declared.

I am not the author but I will update the documentation.

Thanks.