[Share-panel] Change the apps' name when the language is changed 02/47202/1 tizen
authorJin Yoon <jinny.yoon@samsung.com>
Tue, 1 Sep 2015 03:06:48 +0000 (12:06 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Tue, 1 Sep 2015 03:06:48 +0000 (12:06 +0900)
Change-Id: I8841bb3b99fd98e2286a10754b1a07ef7ce9b8fe

CMakeLists.txt
src/grid.c
src/list.c
src/ui_manager.c

index fc8f1b1..27fa9b9 100644 (file)
@@ -45,6 +45,7 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -O2")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
+ADD_DEFINITIONS("-DPROJECT=\"${PROJECT_NAME}\"")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
 ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
index 0ef0982..34893ee 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <Elementary.h>
 #include <app.h>
+#include <app_manager.h>
 #include <aul.h>
 
 #include "share_panel_internal.h"
@@ -23,6 +24,8 @@
 #include "grid.h"
 #include "log.h"
 
+#define PRIVATE_DATA_KEY_ITEM_INFO "pdkii"
+
 
 
 static const char *const FILE_LAYOUT_EDJ = EDJEDIR"/layout.edj";
@@ -127,6 +130,7 @@ static Evas_Object *__content_get(void *data, Evas_Object *obj, const char *part
 static void __del(void *data, Evas_Object *obj)
 {
        ret_if(NULL == data);
+       evas_object_data_del(obj, PRIVATE_DATA_KEY_ITEM_INFO);
 }
 
 
@@ -160,8 +164,37 @@ static void __item_selected(void *data, Evas_Object *obj, void *event_info)
 
 static void __lang_changed_cb(void *data, Evas_Object *grid, void *event_info)
 {
+       Elm_Object_Item *it = NULL;
+       int ret = 0;
        ret_if(!grid);
-       elm_gengrid_realized_items_update(grid);
+
+       it = elm_gengrid_first_item_get(grid);
+       while (it) {
+               app_info_h app_info = NULL;
+               item_s *item_info = NULL;
+               char *name = NULL;
+
+               item_info = evas_object_data_get(it, PRIVATE_DATA_KEY_ITEM_INFO);
+               goto_if(!item_info, next);
+
+               ret = app_info_create(item_info->appid, &app_info);
+               goto_if(ret != APP_MANAGER_ERROR_NONE && !app_info, next);
+
+               ret = app_info_get_label(app_info, &name);
+               if (ret == APP_MANAGER_ERROR_NONE && name) {
+                       free(item_info->name);
+                       item_info->name = name;
+                       elm_object_item_part_text_set(it, "elm.text", item_info->name);
+                       elm_gengrid_item_update(it);
+               } else {
+                       _E("fail to create the app_name from app_info");
+               }
+
+               app_info_destroy(app_info);
+
+next:
+               it = elm_gengrid_item_next_get(it);
+       }
 }
 
 
@@ -225,6 +258,7 @@ Elm_Object_Item *_grid_append_item(Evas_Object *grid, item_s *item_info)
 
        item = elm_gengrid_item_append(grid, grid_info.gic, item_info, __item_selected, item_info);
        retv_if(!item, NULL);
+       evas_object_data_set(item, PRIVATE_DATA_KEY_ITEM_INFO, item_info);
        if (item_info->name) {
                _D("grid append item : %s", item_info->name);
        }
@@ -247,6 +281,7 @@ void _grid_remove_item(Evas_Object *grid, item_s *item_info)
        item = item_info->grid_item;
 
        ret_if(!item);
+       evas_object_data_del(item, PRIVATE_DATA_KEY_ITEM_INFO);
        elm_object_item_del(item);
        item_info->grid_item = NULL;
 }
index 15d61c7..9fee49e 100644 (file)
@@ -272,6 +272,7 @@ static void __make_applist(bundle *b, Eina_List *matchlist, Eina_List **applist)
 {
        Eina_List *l;
        char *data = NULL;
+       int ret = 0;
 
        ret_if(!b);
 
@@ -280,42 +281,49 @@ static void __make_applist(bundle *b, Eina_List *matchlist, Eina_List **applist)
                app_info_h app_info = NULL;
 
                app_s = (item_s *) malloc(sizeof(item_s));
-               break_if(!app_s);
+               continue_if(!app_s);
 
                app_s->appid = strdup(data);
                if (!app_s->appid) {
                        _E("strdup error");
                        free(app_s);
-                       break;
+                       continue;
                }
                app_s->b = b;
 
-               app_info_create(data, &app_info);
-               if (!app_info) {
+               ret = app_info_create(data, &app_info);
+               if (ret != APP_MANAGER_ERROR_NONE || !app_info) {
                        _E("fail to create the app_info");
                        free(app_s->appid);
                        free(app_s);
-                       break;
+                       continue;
                }
 
-               app_info_get_label(app_info, &app_s->name);
-               if (!app_s->name) {
+               ret = app_info_get_label(app_info, &app_s->name);
+               if (ret != APP_MANAGER_ERROR_NONE || !app_s->name) {
                        _E("fail to create the app_name from app_info");
                        free(app_s->appid);
                        free(app_s);
                        app_info_destroy(app_info);
-                       break;
+                       continue;
                }
                _SD("icon_name : [%s]", app_s->name);
 
-               app_info_get_icon(app_info, &app_s->icon);
-               _SD("icon_path : [%s]", app_s->icon);
+               ret = app_info_get_icon(app_info, &app_s->icon);
+               if (ret != APP_MANAGER_ERROR_NONE) {
+                       free(app_s->appid);
+                       free(app_s->name);
+                       free(app_s);
+                       app_info_destroy(app_info);
+                       continue;
+               }
 
                app_info_destroy(app_info);
 
                if (!app_s->icon) {
                        app_s->icon = strdup(DEFAULT_ICON);
                }
+               _SD("icon_path : [%s]", app_s->icon);
 
                *applist = eina_list_sorted_insert(*applist, __applist_compare, app_s);
        }
index 5a24ab6..2a64024 100644 (file)
@@ -192,6 +192,7 @@ Evas_Object *_ui_manager_create(share_panel_s *share_panel)
        goto_if(!__create_back_btn(ui_manager, share_panel), ERROR);
 
        elm_object_part_text_set(ui_manager, "title", _("IDS_AM_HEADER_SHARE"));
+       elm_object_domain_translatable_part_text_set(ui_manager, "title", PROJECT, "IDS_AM_HEADER_SHARE");
 
        share_panel->index = _index_create(ui_manager, 0);
        goto_if(!share_panel->index, ERROR);