apply utils to view_home for creating widget 39/41839/2
authorSoohye Shin <soohye.shin@samsung.com>
Thu, 18 Jun 2015 06:17:37 +0000 (15:17 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Thu, 18 Jun 2015 07:23:38 +0000 (16:23 +0900)
Change-Id: Ie19d6032d542ce77a935e98457071af835b61e5a
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
src/view/view_home.c

index f01ad53..c21af95 100644 (file)
@@ -24,6 +24,7 @@
 #include "view_home.h"
 #include "data_home.h"
 #include "datamgr.h"
+#include "utils.h"
 
 struct _priv {
        Evas_Object *win;
@@ -40,98 +41,6 @@ struct bar_item {
        struct _priv *priv;
 };
 
-static inline Evas_Object *_add_layout(Evas_Object *base, const char *group,
-               bool focus_allow)
-{
-       Evas_Object *ly;
-
-       if (!base || !group) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
-       ly = elm_layout_add(base);
-       if (!ly) {
-               _ERR("failed to add layout");
-               return false;
-       }
-       elm_layout_file_set(ly, EDJEFILE, group);
-       if (focus_allow)
-               elm_object_focus_allow_set(ly, EINA_TRUE);
-       evas_object_show(ly);
-
-       return ly;
-}
-
-static inline Evas_Object *_add_icon(Evas_Object *eo, const char *file, const char *part)
-{
-       Evas_Object *ic;
-
-       if (!eo || !file || !part) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
-       ic = elm_icon_add(eo);
-       if (!ic) {
-               _ERR("failed to add icon");
-               return NULL;
-       }
-
-       elm_image_file_set(ic, file, NULL);
-       elm_object_part_content_set(eo, part, ic);
-
-       return ic;
-}
-
-static inline Evas_Object *_add_label(Evas_Object *eo, char *name,
-               const char *style, const char *part)
-{
-       Evas_Object *lbl;
-       const char *s;
-
-       if (!eo || !name || !style || !part) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
-       lbl = elm_label_add(eo);
-       if (!lbl) {
-               _ERR("failed to add label");
-               return NULL;
-       }
-       elm_object_style_set(lbl, style);
-       s = edje_object_data_get(elm_layout_edje_get(eo), TITLE_WIDTH);
-       if (s)
-               elm_label_wrap_width_set(lbl, atoi(s));
-       elm_object_text_set(lbl, name);
-       elm_object_part_content_set(eo, part, lbl);
-
-       return lbl;
-}
-
-static inline Evas_Object *_add_bg(Evas_Object *eo, const char *part)
-{
-       Evas_Object *bg;
-
-       if (!eo || !part) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
-       bg = evas_object_rectangle_add(evas_object_evas_get(eo));
-       if (!bg) {
-               _ERR("failed to add label");
-               return NULL;
-       }
-
-       evas_object_color_set(bg, COLOR_DEFAULT_R, COLOR_DEFAULT_G,
-                       COLOR_DEFAULT_B, COLOR_DEFAULT_A);
-       elm_object_part_content_set(eo, part, bg);
-
-       return bg;
-}
-
 static bool _add_navigations(Evas_Object *base)
 {
        Evas_Object *ly;
@@ -141,19 +50,17 @@ static bool _add_navigations(Evas_Object *base)
                return false;
        }
 
-       ly = _add_layout(base, GRP_HOME_DOWN_ARROW, true);
+       ly = utils_add_layout(base, GRP_HOME_DOWN_ARROW, true, PART_HOME_DOWN_ARROW);
        if (!ly) {
                _ERR("failed to add layout");
                return false;
        }
-       elm_object_part_content_set(base, PART_HOME_DOWN_ARROW, ly);
 
-       ly = _add_layout(base, GRP_HOME_UP_ARROW, true);
+       ly = utils_add_layout(base, GRP_HOME_UP_ARROW, true, PART_HOME_UP_ARROW);
        if (!ly) {
                _ERR("failed to add layout");
                return false;
        }
-       elm_object_part_content_set(base, PART_HOME_UP_ARROW, ly);
 
        return true;
 }
@@ -202,31 +109,32 @@ static struct bar_item *_pack_bar_item(struct _priv *priv, Evas_Object *box,
                return NULL;
        }
 
-       eo = _add_layout(box, GRP_HOME_ITEM, true);
+       eo = utils_add_layout(box, GRP_HOME_ITEM, true, NULL);
        if (!eo) {
                _ERR("failed to add layout");
                free(bi);
                return NULL;
        }
 
-       ic = _add_icon(eo, di->icon, PART_HOME_ITEM_ICON);
+       ic = utils_add_icon(eo, di->icon, PART_HOME_ITEM_ICON);
        if (!ic)
                goto err;
 
-       focus_ic = _add_icon(eo, di->focus_icon, PART_HOME_ITEM_ICON_FOCUS);
+       focus_ic = utils_add_icon(eo, di->focus_icon, PART_HOME_ITEM_ICON_FOCUS);
        if (!focus_ic)
                goto err;
 
-       lbl = _add_label(eo, di->title, STYLE_LABEL_TITLE, PART_HOME_ITEM_TITLE);
+       lbl = utils_add_label(eo, di->title, STYLE_LABEL_TITLE, PART_HOME_ITEM_TITLE);
        if (!lbl)
                goto err;
 
-       focus_lbl = _add_label(eo, di->title, STYLE_LABEL_TITLE_FOCUS,
+       focus_lbl = utils_add_label(eo, di->title, STYLE_LABEL_TITLE_FOCUS,
                        PART_HOME_ITEM_TITLE_FOCUS);
        if (!focus_lbl)
                goto err;
 
-       bg = _add_bg(eo, PART_HOME_ITEM_BG);
+       bg = utils_add_bg(eo, COLOR_DEFAULT_R, COLOR_DEFAULT_G, COLOR_DEFAULT_B,
+                       COLOR_DEFAULT_A, PART_HOME_ITEM_BG);
        if (!bg)
                goto err;
 
@@ -257,24 +165,20 @@ static bool _add_home_menu(struct _priv *priv, Evas_Object *base)
                return false;
        }
 
-       scr = elm_scroller_add(base);
+       scr = utils_add_scroller(base);
        if (!scr) {
                _ERR("failed to add scroller");
                return false;
        }
-       elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,
-                       ELM_SCROLLER_POLICY_OFF);
 
-       box = elm_box_add(scr);
+       box = utils_add_box(scr, true);
        if (!box) {
                _ERR("failed to add box");
                evas_object_del(scr);
                return false;
        }
-       evas_object_show(box);
        elm_object_content_set(scr, box);
        elm_object_part_content_set(base, PART_HOME_MENU_BAR, scr);
-       elm_box_horizontal_set(box, EINA_TRUE);
 
        list = datamgr_get_items(priv->dm);
        if (!list) {
@@ -363,7 +267,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       base =_add_layout(win, GRP_HOME, false);
+       base = utils_add_layout(win, GRP_HOME, false, NULL);
        if (!base) {
                _ERR("failed to create base");
                datamgr_fini(dm);