add struct icon_info in utils 52/43352/1
authorSoohye Shin <soohye.shin@samsung.com>
Wed, 8 Jul 2015 08:36:25 +0000 (17:36 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Wed, 8 Jul 2015 08:37:26 +0000 (17:37 +0900)
Change-Id: I4423ae370dbf25dc115a035650ecec2b3dbf0fd9
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
include/defs.h
include/utils.h
src/utils.c
src/view/view_user_edit.c

index 34cf03c..5a7efbb 100644 (file)
@@ -25,6 +25,7 @@
 
 #define SRC_PROG "prog"
 #define SRC_EDJE "edje"
+#define ICON_ADD "add"
 
 #define GRP_HOME "group.home"
 #define GRP_HOME_UP_ARROW "group.home.up.arrow"
 #define IMAGE_RECENT_DELETE_DIS IMAGEDIR"/btn_bar_clearall_dis.png"
 #define IMAGE_RECENT_APP IMAGEDIR"/ic_thumbnail_app.png"
 
+#define MAX_ITEM_COUNT 8
+
 #endif /* __AIR_HOME_DEFS_H__ */
index 0f3688e..f57ee51 100644 (file)
 #include <stdbool.h>
 #include <Evas.h>
 
+struct icon_info {
+       const char *icon_file;
+       const char *focus_icon_file;
+       const char *photo_file;
+       const char *focus_photo_file;
+};
+
+struct icon_info *utils_get_icon_info(void);
+const char *utils_get_focus_photo_from_photo(const char *photo);
+const char *utils_get_focus_icon_from_icon(const char *icon);
+const char *utils_get_icon_from_photo(const char *photo);
+const char *utils_get_photo_from_icon(const char *icon);
+
 Evas_Object *utils_add_layout(Evas_Object *base, const char *group,
                bool focus_allow, const char *part);
 Evas_Object *utils_add_icon(Evas_Object *base, const char *file,
index 2fbbbe9..115387d 100644 (file)
 #include "utils.h"
 #include "defs.h"
 
+struct icon_info _icon_info[] = {
+       {
+               IMAGE_USER_DEFAULT,
+               IMAGE_USER_DEFAULT_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT,
+               IMAGE_USER_CURRENT_DEFAULT_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_02,
+               IMAGE_USER_DEFAULT_02_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_02,
+               IMAGE_USER_CURRENT_DEFAULT_02_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_03,
+               IMAGE_USER_DEFAULT_03_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_03,
+               IMAGE_USER_CURRENT_DEFAULT_03_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_04,
+               IMAGE_USER_DEFAULT_04_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_04,
+               IMAGE_USER_CURRENT_DEFAULT_04_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_05,
+               IMAGE_USER_DEFAULT_05_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_05,
+               IMAGE_USER_CURRENT_DEFAULT_05_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_06,
+               IMAGE_USER_DEFAULT_06_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_06,
+               IMAGE_USER_CURRENT_DEFAULT_06_FOCUS
+       },
+       {
+               IMAGE_USER_DEFAULT_07,
+               IMAGE_USER_DEFAULT_07_FOCUS,
+               IMAGE_USER_CURRENT_DEFAULT_07,
+               IMAGE_USER_CURRENT_DEFAULT_07_FOCUS
+       },
+       {
+               IMAGE_USER_ADD,
+               IMAGE_USER_ADD_FOCUS,
+               ICON_ADD,
+               ICON_ADD
+       }
+};
+
+struct icon_info *utils_get_icon_info(void)
+{
+       return _icon_info;
+}
+
+const char *utils_get_focus_photo_from_photo(const char *photo)
+{
+       int i;
+
+       for (i = 0; i < MAX_ITEM_COUNT; i++) {
+               if (!strcmp(photo, _icon_info[i].photo_file))
+                       return _icon_info[i].focus_photo_file;
+       }
+
+       return photo;
+}
+
+const char *utils_get_focus_icon_from_icon(const char *icon)
+{
+       int i;
+
+       for (i = 0; i < MAX_ITEM_COUNT; i++) {
+               if (!strcmp(icon, _icon_info[i].icon_file))
+                       return _icon_info[i].focus_icon_file;
+       }
+
+       return icon;
+}
+
+const char *utils_get_icon_from_photo(const char *photo)
+{
+       int i;
+
+       for (i = 0; i < MAX_ITEM_COUNT; i++) {
+               if (!strcmp(photo, _icon_info[i].photo_file))
+                       return _icon_info[i].icon_file;
+       }
+
+       return photo;
+}
+
+const char *utils_get_photo_from_icon(const char *icon)
+{
+       int i;
+
+       for (i = 0; i < MAX_ITEM_COUNT; i++) {
+               if (!strcmp(icon, _icon_info[i].icon_file))
+                       return _icon_info[i].photo_file;
+       }
+
+       return icon;
+}
+
 Evas_Object *utils_add_layout(Evas_Object *base, const char *group,
                bool focus_allow, const char *part)
 {
index d488200..a433c04 100644 (file)
@@ -38,7 +38,6 @@
 #define MESSAGE_ENTRY_NAME "User Name"
 #define MESSAGE_ENTRY_ACCOUNT "sample@tizen.com"
 #define MESSAGE_ENTRY_PIN "Pin code"
-#define ICON_ADD "add"
 #define KEY_ICON "icon"
 #define KEY_FOCUS_ICON "focusicon"
 
@@ -191,7 +190,8 @@ static input_handler icon_handler = {
        .key_down = _eo_key_down
 };
 
-static Evas_Object *_pack_icon(Evas_Object *table, struct _icon_info *icon_info, int i)
+static Evas_Object *_pack_icon(Evas_Object *table, struct icon_info *_icon_info,
+               int i)
 {
        Evas_Object *eo, *ic, *focus_ic;
 
@@ -203,22 +203,23 @@ static Evas_Object *_pack_icon(Evas_Object *table, struct _icon_info *icon_info,
        evas_object_show(eo);
        elm_table_pack(table, eo, i % 4, i / 4, 1, 1);
 
-       ic = utils_add_icon(eo, icon_info->file, PART_USER_EDIT_ICON_LIST_ITEM);
+       ic = utils_add_icon(eo, _icon_info->icon_file,
+                       PART_USER_EDIT_ICON_LIST_ITEM);
        if (!ic) {
                _ERR("failed to add icon");
                evas_object_del(eo);
                return NULL;
        }
 
-       focus_ic = utils_add_icon(eo, icon_info->focus_file,
+       focus_ic = utils_add_icon(eo, _icon_info->focus_icon_file,
                        PART_USER_EDIT_ICON_LIST_ITEM_FOCUS);
        if (!focus_ic) {
                _ERR("failed to add focus icon");
                evas_object_del(eo);
                return NULL;
        }
-       evas_object_data_set(eo, KEY_ICON, icon_info->message);
-       evas_object_data_set(eo, KEY_FOCUS_ICON, icon_info->focus_message);
+       evas_object_data_set(eo, KEY_ICON, _icon_info->photo_file);
+       evas_object_data_set(eo, KEY_FOCUS_ICON, _icon_info->focus_photo_file);
 
        return eo;
 }
@@ -228,56 +229,7 @@ static void _add_icon_list(struct _priv *priv)
        Evas_Coord x, y, w, h;
        Evas_Object *ctxpopup, *ly, *table, *eo;
        int i;
-       struct _icon_info icon_info[] = {
-               {
-                       IMAGE_USER_DEFAULT,
-                       IMAGE_USER_DEFAULT_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT,
-                       IMAGE_USER_CURRENT_DEFAULT_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_02,
-                       IMAGE_USER_DEFAULT_02_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_02,
-                       IMAGE_USER_CURRENT_DEFAULT_02_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_03,
-                       IMAGE_USER_DEFAULT_03_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_03,
-                       IMAGE_USER_CURRENT_DEFAULT_03_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_04,
-                       IMAGE_USER_DEFAULT_04_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_04,
-                       IMAGE_USER_CURRENT_DEFAULT_04_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_05,
-                       IMAGE_USER_DEFAULT_05_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_05,
-                       IMAGE_USER_CURRENT_DEFAULT_05_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_06,
-                       IMAGE_USER_DEFAULT_06_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_06,
-                       IMAGE_USER_CURRENT_DEFAULT_06_FOCUS
-               },
-               {
-                       IMAGE_USER_DEFAULT_07,
-                       IMAGE_USER_DEFAULT_07_FOCUS,
-                       IMAGE_USER_CURRENT_DEFAULT_07,
-                       IMAGE_USER_CURRENT_DEFAULT_07_FOCUS
-               },
-               {
-                       IMAGE_USER_ADD,
-                       IMAGE_USER_ADD_FOCUS,
-                       ICON_ADD,
-                       ICON_ADD
-               }
-       };
+       struct icon_info *_icon_info;
 
        ctxpopup = elm_ctxpopup_add(priv->base);
        if (!ctxpopup) {
@@ -313,8 +265,10 @@ static void _add_icon_list(struct _priv *priv)
        evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND,
                        EVAS_HINT_EXPAND);
 
-       for (i = 0; i < sizeof(icon_info) / sizeof(*icon_info); i++) {
-               eo = _pack_icon(table, &icon_info[i], i);
+       _icon_info = utils_get_icon_info();
+
+       for (i = 0; i < MAX_ITEM_COUNT; i++) {
+               eo = _pack_icon(table, &_icon_info[i], i);
                if (!eo)
                        continue;