Apply winset changes - genlist
authorEunmi Son <eunmi.son@samsung.com>
Mon, 10 Dec 2012 05:53:12 +0000 (14:53 +0900)
committerEunmi Son <eunmi.son@samsung.com>
Mon, 10 Dec 2012 05:53:12 +0000 (14:53 +0900)
Change-Id: Ibf0b6e73e8a7526c39ebfbffe567f045e86d2db8

view/src/mgr-app-view-app-info.c
view/src/mgr-app-view-app-list.c

index d4861af..0605e29 100755 (executable)
 #define ELM_TEXT_1                                     "elm.text.1"
 #define ELM_TEXT_2                                     "elm.text.2"
 #define ELM_TEXT                                       "elm.text"
-#define ELM_ICON_1                                     "elm.icon.1"
-#define ELM_ICON_2                                     "elm.icon.2"
+#define ELM_ICON                                       "elm.icon"
 #define ELM_BUTTON_STYLE                       "popup_button/default"
 
 #define ITC_ITEM_STYLE                         "dialogue/2text.1icon.2"
-#define ITC_LIFE_ITEM_STYLE                    "dialogue/bg/2icon"
+//#define ITC_LIFE_ITEM_STYLE                  "dialogue/bg/2icon"
+#define ITC_LIFE_ITEM_STYLE                    "1icon/with_no_line"
 #define ITC_STO_TITLE_ITEM_STYLE       "dialogue/title"
 #define ITC_STO_TOTAL_ITEM_STYLE       "dialogue/2text.2"
 #define ITC_STO_APP_ITEM_STYLE                 "dialogue/2text.2"
@@ -78,6 +78,13 @@ struct _app_info_view_data_t {
        mgr_app_app_info_t      *app_info;
 };
 
+enum {
+       ELM_STATE_TOP = 0,
+       ELM_STATE_BOTTOM,
+       ELM_STATE_CENTER,
+       ELM_STATE_DEFAULT,
+};
+
 static Evas_Object *mgr_app_view_app_info_create(void *data);
 static Evas_Object *mgr_app_view_app_info_set_cbar(void *data);
 static mgr_app_result_e mgr_app_view_app_info_set_navibar(void *data);
@@ -97,7 +104,8 @@ mgr_app_view_t mgr_app_view_app_info = {
 };
 
 static Elm_Genlist_Item_Class *itc                     = NULL;
-static Elm_Genlist_Item_Class *itc_life        = NULL;
+static Elm_Genlist_Item_Class *itc_forcestop= NULL;
+static Elm_Genlist_Item_Class *itc_uninstall= NULL;
 static Elm_Genlist_Item_Class *itc_sto_title= NULL;
 static Elm_Genlist_Item_Class *itc_sto_total= NULL;
 static Elm_Genlist_Item_Class *itc_sto_app     = NULL;
@@ -111,6 +119,7 @@ static Elm_Genlist_Item_Class *itc_sep_10   = NULL;
 static Elm_Genlist_Item_Class *itc_sep_20      = NULL;
 static Elm_Genlist_Item_Class *itc_sep_21      = NULL;
 
+static mgr_app_app_info_t *_app_info = NULL;
 
 static void _app_info_next_cb(void *data, Evas_Object *obj, void *event_info)
 {
@@ -145,7 +154,8 @@ void _app_info_back_cb(void *data, Evas_Object *obj, void *event_info)
        elm_genlist_item_class_free(itc_sep_21);
        elm_genlist_item_class_free(itc);
        elm_genlist_item_class_free(itc_sep_10);
-       elm_genlist_item_class_free(itc_life);
+       elm_genlist_item_class_free(itc_forcestop);
+       elm_genlist_item_class_free(itc_uninstall);
        elm_genlist_item_class_free(itc_sto_title);
        elm_genlist_item_class_free(itc_sto_total);
        elm_genlist_item_class_free(itc_sto_app);
@@ -163,8 +173,8 @@ static void _force_stop_clicked_cb(void *data, Evas_Object *obj, void *event_inf
 {
        MGR_APP_BEGIN();
 
-       ret_if(data == NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       ret_if(_app_info == NULL);
+       mgr_app_app_info_t *app_info = _app_info;
        ret_if(app_info->pkg_name == NULL);
        bool is_running = false;
        int ret = APP_MANAGER_ERROR_NONE;
@@ -262,8 +272,8 @@ static void _uninstall_by_pkgmgr_cb(void *data, Evas_Object *obj, void *event_in
        MGR_APP_BEGIN();
 
        ret_if(obj == NULL);
-       ret_if(data == NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       ret_if(_app_info == NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        ret_if(mgr_app_view_app_info.view_common_data == NULL);
        mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
@@ -338,8 +348,8 @@ static void _uninstall_clicked_cb(void *data, Evas_Object *obj, void *event_info
        ret_if(obj == NULL);
        Evas_Object *btn_uninstall = obj;
 
-       ret_if(data == NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       ret_if(_app_info == NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        ret_if(mgr_app_view_app_info.view_common_data == NULL);
        mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
@@ -406,8 +416,8 @@ static void _gl_sel_launch(void *data, Evas_Object *obj, void *event_info)
        ret_if(data == NULL);
        struct ug_data *ugd = (struct ug_data*)data;
 
-       ret_if(ugd->data == NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
+       ret_if(_app_info == NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        ret_if(app_info->pkg_name == NULL);
        char *package_name = NULL;
@@ -659,8 +669,8 @@ static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
 {
        MGR_APP_BEGIN();
 
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        char *label = NULL;
 
@@ -692,8 +702,8 @@ static char *_gl_label_get_sto_total(void *data, Evas_Object *obj, const char *p
 {
        MGR_APP_BEGIN();
 
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        char *label = NULL;
 
@@ -716,8 +726,8 @@ static char *_gl_label_get_sto_app(void *data, Evas_Object *obj, const char *par
 {
        MGR_APP_BEGIN();
 
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        char *label = NULL;
 
@@ -740,8 +750,8 @@ static char *_gl_label_get_sto_data(void *data, Evas_Object *obj, const char *pa
 {
        MGR_APP_BEGIN();
 
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        char *label = NULL;
 
@@ -815,8 +825,8 @@ static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
 {
        MGR_APP_BEGIN();
 
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        Evas_Object *icon = NULL;
        char *icon_path = NULL;
@@ -839,16 +849,16 @@ static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
        return icon;
 }
 
-static Evas_Object *_gl_icon_get_life(void *data, Evas_Object *obj, const char *part)
+static Evas_Object *_gl_icon_get_forcestop(void *data, Evas_Object *obj, const char *part)
 {
        MGR_APP_BEGIN();
 
        MGR_APP_DEBUG("part:%s\n", part);
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        Evas_Object *button = NULL;
-       if (!strncmp(part, ELM_ICON_1, strlen(ELM_ICON_1))) {
+       if (!strncmp(part, ELM_ICON, strlen(ELM_ICON))) {
                button = elm_button_add(obj);
                if (button) {
                        elm_object_disabled_set(button, EINA_TRUE);
@@ -876,7 +886,25 @@ static Evas_Object *_gl_icon_get_life(void *data, Evas_Object *obj, const char *
                                }
                        }
                }
-       } else if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
+       } else {
+               MGR_APP_DEBUG_ERR("elm icon part is wrong");
+               button = NULL;
+       }
+
+       MGR_APP_END();
+       return button;
+}
+
+static Evas_Object *_gl_icon_get_uninstall(void *data, Evas_Object *obj, const char *part)
+{
+       MGR_APP_BEGIN();
+
+       MGR_APP_DEBUG("part:%s\n", part);
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
+
+       Evas_Object *button = NULL;
+       if (!strncmp(part, ELM_ICON, strlen(ELM_ICON))) {
                button = elm_button_add(obj);
                if (button) {
                        elm_object_disabled_set(button, EINA_TRUE);
@@ -902,11 +930,11 @@ static Evas_Object *_gl_icon_get_data(void *data, Evas_Object *obj, const char *
        MGR_APP_BEGIN();
 
        MGR_APP_DEBUG("part:%s\n", part);
-       retv_if(data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
+       retv_if(_app_info == NULL, NULL);
+       mgr_app_app_info_t *app_info = _app_info;
 
        Evas_Object *button = NULL;
-       if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
+       if (!strncmp(part, ELM_ICON, strlen(ELM_ICON))) {
                button = elm_button_add(obj);
                if (button) {
                        elm_object_text_set(button, dgettext(PACKAGE, "IDS_ST_BUTTON_CLEAR_DATA"));
@@ -938,6 +966,25 @@ static char *_gl_label_get_title(void *data, Evas_Object *obj, const char *part)
        return title;
 }
 
+static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
+{
+       MGR_APP_BEGIN();\r
+
+       ret_if(event_info == NULL);
+
+       int type = (int)elm_object_item_data_get(event_info);
+
+       if (type == ELM_STATE_TOP) {
+               elm_object_item_signal_emit(event_info, "elm,state,top", "");
+       } else if (type == ELM_STATE_CENTER) {
+               elm_object_item_signal_emit(event_info, "elm,state,center", "");
+       } else if (type == ELM_STATE_BOTTOM) {
+               elm_object_item_signal_emit(event_info, "elm,state,bottom", "");
+       }
+
+       MGR_APP_END();
+}
+
 static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 {
        MGR_APP_BEGIN();
@@ -946,7 +993,8 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
        struct ug_data *ugd = (struct ug_data*)data;
 
        Elm_Object_Item *item_app                       = NULL;
-       Elm_Object_Item *item_life                      = NULL;
+       Elm_Object_Item *item_forcestop = NULL;
+       Elm_Object_Item *item_uninstall = NULL;
        Elm_Object_Item *item_sto_title         = NULL;
        Elm_Object_Item *item_sto_total = NULL;
        Elm_Object_Item *item_sto_app           = NULL;
@@ -974,8 +1022,10 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
        retv_if(itc == NULL, NULL);
        itc_sep_10 = elm_genlist_item_class_new();
        retv_if(itc_sep_10 == NULL, NULL);
-       itc_life = elm_genlist_item_class_new();
-       retv_if(itc_life == NULL, NULL);
+       itc_forcestop = elm_genlist_item_class_new();
+       retv_if(itc_forcestop == NULL, NULL);
+       itc_uninstall = elm_genlist_item_class_new();
+       retv_if(itc_uninstall == NULL, NULL);
        itc_sto_title = elm_genlist_item_class_new();
        retv_if(itc_sto_title == NULL, NULL);
        itc_sto_total = elm_genlist_item_class_new();
@@ -1019,11 +1069,17 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
        itc_sep_10->func.state_get              = NULL;
        itc_sep_10->func.del                    = NULL;
 
-       itc_life->item_style                    = ITC_LIFE_ITEM_STYLE;
-       itc_life->func.text_get                 = NULL;
-       itc_life->func.content_get              = _gl_icon_get_life;
-       itc_life->func.state_get                = NULL;
-       itc_life->func.del                              = NULL;
+       itc_forcestop->item_style               = ITC_LIFE_ITEM_STYLE;
+       itc_forcestop->func.text_get    = NULL;
+       itc_forcestop->func.content_get = _gl_icon_get_forcestop;
+       itc_forcestop->func.state_get   = NULL;
+       itc_forcestop->func.del                         = NULL;
+
+       itc_uninstall->item_style               = ITC_LIFE_ITEM_STYLE;
+       itc_uninstall->func.text_get    = NULL;
+       itc_uninstall->func.content_get = _gl_icon_get_uninstall;
+       itc_uninstall->func.state_get   = NULL;
+       itc_uninstall->func.del                 = NULL;
 
        itc_sto_title->item_style               = ITC_STO_TITLE_ITEM_STYLE;
        itc_sto_title->func.text_get    = _gl_label_get_title;
@@ -1079,7 +1135,6 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
        itc_detail->func.state_get              = NULL;
        itc_detail->func.del                    = NULL;
 
-
        retv_if(ugd->data == NULL, NULL);
        mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
 
@@ -1119,15 +1174,15 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
        elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
        elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
        evas_object_data_set(genlist, STR_UGD, (void*)ugd);
-       elm_object_style_set(genlist, "dialogue");
        evas_object_show(genlist);
+       evas_object_smart_callback_add(genlist, "realized", _gl_realized, NULL);
 
        MGR_APP_MEM_STRDUP(sto_title, dgettext(PACKAGE, "IDS_ST_BODY_STORAGE"));
        MGR_APP_MEM_STRDUP(launch_title, dgettext(PACKAGE, "IDS_ST_BODY_LAUNCH_BY_DEFAULT"));
 
 
        /* app info */
-       item_app = elm_genlist_item_append(genlist, itc, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       item_app = elm_genlist_item_append(genlist, itc, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        if (item_app)
                elm_genlist_item_select_mode_set(item_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
@@ -1139,18 +1194,22 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 
 
        /* Force stop & Uninstall */
-       item_life = elm_genlist_item_append(genlist, itc_life, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
-
+       item_forcestop = elm_genlist_item_append(genlist, itc_forcestop, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       if (item_forcestop)
+               elm_genlist_item_select_mode_set(item_forcestop, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       item_uninstall = elm_genlist_item_append(genlist, itc_uninstall, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       if (item_uninstall)
+               elm_genlist_item_select_mode_set(item_uninstall, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
        /* Storage */
        item_sto_title = elm_genlist_item_append(genlist, itc_sto_title, sto_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
-       item_sto_total = elm_genlist_item_append(genlist, itc_sto_total, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       item_sto_total = elm_genlist_item_append(genlist, itc_sto_total, ELM_STATE_TOP, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        if (item_sto_total)
                elm_genlist_item_select_mode_set(item_sto_total, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-       item_sto_app = elm_genlist_item_append(genlist, itc_sto_app, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       item_sto_app = elm_genlist_item_append(genlist, itc_sto_app, ELM_STATE_CENTER, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        if (item_sto_app)
                elm_genlist_item_select_mode_set(item_sto_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-       item_sto_data = elm_genlist_item_append(genlist, itc_sto_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       item_sto_data = elm_genlist_item_append(genlist, itc_sto_data, ELM_STATE_BOTTOM, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        if (item_sto_data)
                elm_genlist_item_select_mode_set(item_sto_data, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
@@ -1175,12 +1234,12 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 
        /* Launch */
        item_launch_title = elm_genlist_item_append(genlist, itc_launch_title, launch_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
-       item_launch = elm_genlist_item_append(genlist, itc_launch, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_launch, (void*)ugd);
+       item_launch = elm_genlist_item_append(genlist, itc_launch, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_launch, (void*)ugd);
        if (item_launch && !appsvc_is_defapp(app_info->pkg_name)) {
                elm_genlist_item_selected_set(item_launch, EINA_FALSE);
                elm_object_item_disabled_set(item_launch, EINA_TRUE);
        }
-       item_launch_text = elm_genlist_item_append(genlist, itc_launch_text, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       item_launch_text = elm_genlist_item_append(genlist, itc_launch_text, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        if (item_launch_text)
                elm_genlist_item_select_mode_set(item_launch_text, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
        item_sep_21 = elm_genlist_item_append(genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
@@ -1189,7 +1248,7 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 
 
        /* More Detail */
-       item_detail = elm_genlist_item_append(genlist, itc_detail, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_detail, (void*)ugd);
+       item_detail = elm_genlist_item_append(genlist, itc_detail, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_detail, (void*)ugd);
        if (app_info->pkg_type) {
                if (item_detail != NULL && (!strncmp(app_info->pkg_type, TPK_PREFIX, strlen(TPK_PREFIX)) || !strncmp(app_info->pkg_type, RPM_PREFIX, strlen(RPM_PREFIX)))) {
                        elm_genlist_item_selected_set(item_detail, EINA_FALSE);
@@ -1228,6 +1287,8 @@ static Evas_Object *mgr_app_view_app_info_create(void *data)
        retv_if(view_common_data->user_view_data == NULL, NULL);
        app_info_view_data_t *app_info_view_data = view_common_data->user_view_data;
 
+       retv_if(ugd->data == NULL, NULL);
+       _app_info = app_info_view_data->app_info = (mgr_app_app_info_t*)ugd->data;
        app_info_view_data->genlist = __create_genlist_app_info(view_common_data->common_navibar, (void*)ugd);
 
        MGR_APP_END();
index 4750339..26a8214 100755 (executable)
@@ -872,6 +872,24 @@ static void _index_del_item_cb(void *data, Evas_Object *obj, void *event_info)
        MGR_APP_END();
 }
 
+static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
+{
+       MGR_APP_BEGIN();
+
+       ret_if(obj == NULL);
+       ret_if(event_info == NULL);
+
+       if (event_info == elm_genlist_item_next_get(elm_genlist_first_item_get(obj))) { // first is a separator
+               elm_object_item_signal_emit(event_info, "elm,state,top", "");
+       } else if (event_info == elm_genlist_item_prev_get(elm_genlist_last_item_get(obj))) { // last is a separator
+               elm_object_item_signal_emit(event_info, "elm,state,bottom", "");
+       } else {
+               elm_object_item_signal_emit(event_info, "elm,state,center", "");
+       }
+
+       MGR_APP_END();
+}
+
 static Evas_Object *__create_genlist_app_list(Evas_Object *parent, void *data)
 {
        MGR_APP_BEGIN();
@@ -933,9 +951,8 @@ static Evas_Object *__create_genlist_app_list(Evas_Object *parent, void *data)
        elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
        elm_genlist_block_count_set(genlist, GENLIST_BLOCK_CNT);
        elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-       elm_object_style_set(genlist, "dialogue");
        evas_object_show(genlist);
-
+       evas_object_smart_callback_add(genlist, "realized", _gl_realized, NULL);
 
        app_list_view_data->genlist = genlist;
        app_list_view_data->index = index;