#define STR_ICON "icon"
#define EDC_FILE EDJDIR"/ug-setting-manage-applications-efl/ug-setting-manage-applications-efl.edj"
-#define EDC_GROUPS "mgr-app-list"
#define ELM_TEXT "elm.text"
#define ITC_ITEM_STYLE "dialogue/1text.1icon.2"
#define STR_POPUP_OK "OK"
static Evas_Object *_genlist = NULL;
-static Evas_Object *_index = NULL;
-static int _index_cnt = 0;
static Eina_Bool _initialize = false;
static GList *_installed_list = NULL;
static int _installed_cnt = 0;
-static int _target_idx = 0;
static Elm_Object_Item *_tabbar_item[VIEW_TYPE_MAX] = {NULL,};
static Elm_Object_Item *_navi_it = NULL;
static Elm_Genlist_Item_Class *itc = NULL;
static Elm_Genlist_Item_Class *itc_sep = NULL;
-static char *_convert_char_to_string(char ch);
-static void _register_index_item(Evas_Object *index, char *letter, Elm_Object_Item *item, Eina_Bool init);
-static void _index_del_item_cb(void *data, Evas_Object *obj, void *event_info);
-static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_data);
-
static void _free_resources(struct ug_data * ugd)
{
MGR_APP_BEGIN();
static void _gl_del(void *data, Evas_Object *obj)
{
MGR_APP_BEGIN();
-
+#if 0
ret_if(data == NULL);
mgr_app_app_info_t *app_info = (mgr_app_app_info_t *)data;
-#if 0
// TODO
MGR_APP_MEM_FREE(app_info->pkg_name);
MGR_APP_MEM_FREE(app_info->pkg_label);
return icon;
}
-static void _index_delayed_changed(void *data, Evas_Object *obj, void *event_info)
-{
- MGR_APP_BEGIN();
- // called on a change but delayed in case multiple changes happen in a
- // short timespan
- elm_genlist_item_bring_in(elm_object_item_data_get(event_info), ELM_GENLIST_ITEM_SCROLLTO_TOP);
- MGR_APP_END();
-}
-
-static void _index_changed(void *data, Evas_Object *obj, void *event_info)
-{
- MGR_APP_BEGIN();
- // this is calld on every change, no matter how often
- MGR_APP_END();
-}
-
-static void _index_selected(void *data, Evas_Object *obj, void *event_info)
-{
- MGR_APP_BEGIN();
- // called on final select
- elm_genlist_item_bring_in(elm_object_item_data_get(event_info), ELM_GENLIST_ITEM_SCROLLTO_TOP);
- MGR_APP_END();
-}
-
-static gint _app_list_qsort_cb(gconstpointer a, gconstpointer b)
-{
- MGR_APP_BEGIN();
-
- retv_if(NULL == a, 0);
- retv_if(NULL == b, 0);
-
- mgr_app_app_info_t *app_info1 = (mgr_app_app_info_t *)a;
- mgr_app_app_info_t *app_info2 = (mgr_app_app_info_t *)b;
- char *pkg_label1 = NULL;
- char *pkg_label2 = NULL;
- int len = 0;
- int r = 0;
-
- pkg_label1 = app_info1->pkg_label;
- pkg_label2 = app_info2->pkg_label;
- retv_if(NULL == pkg_label1, 0);
- retv_if(NULL == pkg_label2, 0);
-
- MGR_APP_DEBUG("pkg_label1: %s", pkg_label1);
- MGR_APP_DEBUG("pkg_label2: %s", pkg_label2);
-
- len = (strlen(pkg_label1) >= strlen(pkg_label2)) ? strlen(pkg_label1) : strlen(pkg_label2);
- r = strncasecmp(pkg_label1, pkg_label2, len);
- if (r >= 0) {
- _target_idx++;
- }
-
- MGR_APP_END();
- return r;
-}
-
static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_pkginfo_h handler, mgr_app_app_info_t *app_info)
{
MGR_APP_BEGIN();
MGR_APP_END();
}
-static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_data)
-{
- MGR_APP_BEGIN();
-
- ret_if(NULL == app_info_new || NULL == user_data);
-
- struct ug_data *ugd = (struct ug_data *)user_data;
- Elm_Object_Item *new_item = NULL;
- Elm_Object_Item *prev_item = NULL;
- Elm_Object_Item *next_item = NULL;
- Elm_Object_Item *index_item = NULL;
- mgr_app_app_info_t *prev_info = NULL;
- mgr_app_app_info_t *next_info = NULL;
- char *letter_new = NULL;
- char *letter = NULL;
- char *letter2 = NULL;
-
- /* insert to genlist */
- if (_target_idx > 1) {
- prev_item = elm_genlist_nth_item_get(_genlist, _target_idx);
- if (NULL == prev_item) {
- MGR_APP_DEBUG_ERR("prev_item is null");
- goto end;
- }
- new_item = elm_genlist_item_insert_after(_genlist, itc, (void*)app_info_new, NULL, prev_item, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
- if (NULL == new_item) {
- MGR_APP_DEBUG_ERR("new_item is null");
- goto end;
- }
- } else {
- new_item = elm_genlist_item_append(_genlist, itc, (void*)app_info_new, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
- if (NULL == new_item) {
- MGR_APP_DEBUG_ERR("new_item is null");
- goto end;
- }
- }
-
- if (NULL == app_info_new->pkg_label) {
- MGR_APP_DEBUG_ERR("pkg_name_new is null");
- goto end;
- }
-
- letter_new = _convert_char_to_string(app_info_new->pkg_label[0]);
- if (NULL == letter_new) {
- MGR_APP_DEBUG_ERR("letter_new is null");
- goto end;
- }
-
-
- /* A' B' are new one */
- /* A' */
- if (_installed_cnt <= 1) {
- _register_index_item(_index, letter_new, new_item, EINA_FALSE);
-
- } else if (_target_idx == 1) {
- next_item = elm_genlist_item_next_get(new_item);
- if (NULL == next_item) {
- MGR_APP_DEBUG_ERR("next_item is null");
- goto end;
- }
- next_info = (mgr_app_app_info_t *)elm_object_item_data_get(next_item);
- if (NULL == next_info) {
- MGR_APP_DEBUG_ERR("next_info is null");
- goto end;
- }
-
- if (NULL == next_info->pkg_label) {
- MGR_APP_DEBUG_ERR("pkg_label is null");
- goto end;
- }
-
- letter = _convert_char_to_string(next_info->pkg_label[0]);
- if (NULL == letter) {
- MGR_APP_DEBUG_ERR("letter is null");
- goto end;
- }
-
- /* remove next letter and insert new letter */
- /* remove and insert operation is executed in index item delete callback */
- /* A' - A */
- if (letter_new[0] == letter[0]) {
- index_item = elm_index_item_find(_index, next_item);
- if (index_item) {
- elm_object_item_del(index_item);
- }
- /* insert new letter */
- /* A' - B */
- } else {
- _register_index_item(_index, letter_new, new_item, EINA_FALSE);
- }
-
- } else if (_target_idx > 1 && _target_idx < _installed_cnt) {
- prev_item = elm_genlist_item_prev_get(new_item);
- if (NULL == prev_item) {
- MGR_APP_DEBUG_ERR("prev_item is null");
- goto end;
- }
- next_item = elm_genlist_item_next_get(new_item);
- if (NULL == next_item) {
- MGR_APP_DEBUG_ERR("next_item is null");
- goto end;
- }
-
- prev_info = (mgr_app_app_info_t *)elm_object_item_data_get(prev_item);
- if (NULL == prev_info) {
- MGR_APP_DEBUG_ERR("prev_info is null");
- goto end;
- }
- next_info = (mgr_app_app_info_t *)elm_object_item_data_get(next_item);
- if (NULL == next_info) {
- MGR_APP_DEBUG_ERR("next_info is null");
- goto end;
- }
-
- if (NULL == prev_info->pkg_label) {
- MGR_APP_DEBUG_ERR("prev_info->pkg_label is null");
- goto end;
- }
- if (NULL == next_info->pkg_label) {
- MGR_APP_DEBUG_ERR("next_info->pkg_label is null");
- goto end;
- }
-
- letter = _convert_char_to_string(prev_info->pkg_label[0]);
- if (NULL == letter) {
- MGR_APP_DEBUG_ERR("letter is null");
- goto end;
- }
- letter2 = _convert_char_to_string(next_info->pkg_label[0]);
- if (NULL == letter2) {
- MGR_APP_DEBUG_ERR("letter2 is null");
- goto end;
- }
-
-#if 0
- /* A - A' - A */
- if (letter[0] == letter2[0]) {
- // Nothing to do
-
- /* A - A' - B */
- } else if (letter[0] == letter_new[0]) {
- // Nothing to do
-
- } else
-#endif
- /* A - B' - C */
- if (letter[0] < letter_new[0] && letter_new[0] < letter2[0]) {
- _register_index_item(_index, letter_new, new_item, EINA_FALSE);
-
- /* A - B' - B */
- } else if (letter_new[0] == letter2[0]) {
- index_item = elm_index_item_find(_index, next_item);
- if (index_item) {
- elm_object_item_del(index_item);
- index_item = NULL;
- }
- }
-
- } else if (_target_idx == _installed_cnt) {
- prev_item = elm_genlist_item_prev_get(new_item);
- if (NULL == prev_item) {
- MGR_APP_DEBUG_ERR("prev_item is null");
- goto end;
- }
- prev_info = (mgr_app_app_info_t *)elm_object_item_data_get(prev_item);
- if (NULL == prev_info) {
- MGR_APP_DEBUG_ERR("prev_info is null");
- goto end;
- }
- if (NULL == prev_info->pkg_label) {
- MGR_APP_DEBUG_ERR("pkg_label is null");
- goto end;
- }
-
- letter = _convert_char_to_string(prev_info->pkg_label[0]);
- if (NULL == letter) {
- MGR_APP_DEBUG_ERR("letter is null");
- goto end;
- }
-
- /* insert new letter */
- /* A - B' */
- if (letter_new[0] > letter[0]) {
- _register_index_item(_index, letter_new, new_item, EINA_FALSE);
- }
- }
-
-
- elm_genlist_realized_items_update(_genlist);
-
-end:
- MGR_APP_MEM_FREE(letter);
- MGR_APP_MEM_FREE(letter2);
- MGR_APP_MEM_FREE(letter_new);
-
- MGR_APP_END();
-}
-
static void _notify_by_uninstall(void *data)
{
MGR_APP_BEGIN();
struct ug_data *ugd = (struct ug_data*)data;
pkgmgr_pkginfo_h pkg_handle = NULL;
mgr_app_app_info_t *app_info = NULL;
+ Elm_Object_Item *item = NULL;
int r = 0;
_initialize = EINA_FALSE;
_get_appinfo_from_pkgmgr(pkg_handle, app_info);
- _target_idx = 1; // 0: genlist separator item
- _installed_list = g_list_insert_sorted(_installed_list, (gpointer)app_info, _app_list_qsort_cb);
+ item = elm_genlist_item_append(_genlist, itc, (void*)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
_installed_cnt++;
- _insert_to_app_list(app_info, (void*)ugd);
-
end:
if (pkg_handle) {
pkgmgr_pkginfo_destroy_pkginfo(pkg_handle);
mgr_app_app_info_t *app_info = NULL;
Elm_Object_Item *item = NULL;
- Elm_Object_Item *idx_item = NULL;
int i = 0;
/* header separator */
ret_if(app_info == NULL);
if (app_info->pkg_name && 0 == strcmp(app_info->pkg_name, pkg_name)) {
- MGR_APP_DEBUG_ERR("in");
- idx_item = elm_index_item_find(_index, item);
- if (idx_item) {
- _index_del_item_cb(item, _index, idx_item);
- elm_object_item_del(idx_item);
- idx_item = NULL;
- }
_installed_list = g_list_remove(_installed_list, app_info);
elm_object_item_del(item);
item = NULL;
return 0;
}
-static char *_convert_char_to_string(char ch)
-{
- MGR_APP_BEGIN();
-
- char *str_buf = NULL;
- str_buf = (char*)malloc(sizeof(char)*MAX_BUF_SIZE);
- retv_if(str_buf == NULL, NULL);
- memset(str_buf, 0, sizeof(char)*MAX_BUF_SIZE);
-
- if (ch >= 'A' && ch <= 'Z') {
- snprintf(str_buf, MAX_BUF_SIZE, "%c", ch);
- } else if (ch >= 'a' && ch <= 'z') {
- snprintf(str_buf, MAX_BUF_SIZE, "%c", ch - 'a' + 'A');
- } else if (ch >= '0' && ch <= '9') {
- snprintf(str_buf, MAX_BUF_SIZE, "%c", ch);
- } else {
- snprintf(str_buf, MAX_BUF_SIZE, "%s", "etc");
- }
-
- MGR_APP_END();
- return str_buf;
-}
-
-static int _compare_index_item_letter_cb(const void *a, const void *b)
-{
- MGR_APP_BEGIN();
-
- retv_if(a == NULL, -1);
- retv_if(b == NULL, -1);
-
- const Elm_Object_Item *it1 = (const Elm_Object_Item*)a;
- const Elm_Object_Item *it2 = (const Elm_Object_Item*)b;
-
- const char *letter1 = elm_index_item_letter_get(it1);
- const char *letter2 = elm_index_item_letter_get(it2);
-
- MGR_APP_DEBUG("letter1: %s, letter2: %s", letter1, letter2);
-
- int len = 0;
- len = (strlen(letter1) >= strlen(letter2)) ? strlen(letter1) : strlen(letter2);
-
- MGR_APP_END();
- return strncasecmp(letter1, letter2, len);
-}
-
-/**
- * _compare_data_index_item_letter_cb be used when _compare_index_item_letter_cb return 0.
- */
-static int _compare_data_index_item_letter_cb(const void *a, const void *b)
-{
- MGR_APP_BEGIN();
-
- retv_if(a == NULL, -1);
- retv_if(b == NULL, -1);
-
- const Elm_Object_Item *it1 = (const Elm_Object_Item*)a;
- const Elm_Object_Item *it2 = (const Elm_Object_Item*)b;
-
- mgr_app_app_info_t *app_info1 = (mgr_app_app_info_t *)elm_object_item_data_get(it1);
- mgr_app_app_info_t *app_info2 = (mgr_app_app_info_t *)elm_object_item_data_get(it2);
- retv_if(app_info1 == NULL, -1);
- retv_if(app_info2 == NULL, -1);
-
- MGR_APP_DEBUG("letter1: %s, letter2: %s", app_info1->pkg_label, app_info2->pkg_label);
-
- MGR_APP_END();
- return 0;
-}
-
-static void _register_index_item(Evas_Object *index, char *letter, Elm_Object_Item *item, Eina_Bool init)
-{
- MGR_APP_BEGIN();
-
- MGR_APP_DEBUG("letter: %s", letter);
-
- Elm_Object_Item *new_index_item = NULL;
- Elm_Object_Item *temp_index_item = NULL;
- Elm_Object_Item *temp_item = NULL;
- char *temp_letter = NULL;
- int i = 0;
-
- if (!init) {
- temp_item = elm_genlist_first_item_get(_genlist);
- ret_if(temp_item == NULL);
-
- for (i = 0; i < _installed_cnt; i++) {
- temp_index_item = elm_index_item_find(index, temp_item);
-
- /* indexed genlist item */
- if (temp_index_item) {
- temp_letter = elm_index_item_letter_get(temp_index_item);
- ret_if(temp_letter == NULL);
-
- if (letter[0] < temp_letter[0]) {
- elm_index_item_insert_before(index, temp_item, letter, NULL, item);
- break;
- }
- }
- temp_item = elm_genlist_item_next_get(temp_item);
- }
- } else {
- elm_index_item_append(index, letter, NULL, item);
- }
-
- new_index_item = elm_index_item_find(index, item);
- ret_if(new_index_item == NULL);
- //elm_object_item_del_cb_set(new_index_item, _index_del_item_cb);
- elm_object_item_data_set(new_index_item, (void*)item);
-
- _index_cnt++;
-
- MGR_APP_END();
-}
-
-static void _index_del_item_cb(void *data, Evas_Object *obj, void *event_info)
-{
- MGR_APP_BEGIN();
-
- ret_if(data == NULL);
- Elm_Object_Item *item = (Elm_Object_Item*)data;
- Elm_Object_Item *next_item = NULL;
- Elm_Object_Item *prev_item = NULL;
- Elm_Object_Item *index_item = NULL;
- mgr_app_app_info_t *next_app_info = NULL;
- char *next_letter = NULL;
- char *letter = NULL;
-
- /* change the index item */
- next_item = elm_genlist_item_next_get(item);
-
- if (next_item) {
- next_app_info = (mgr_app_app_info_t *)elm_object_item_data_get(next_item);
- ret_if(next_app_info == NULL);
-
- index_item = (Elm_Object_Item*)event_info;
- ret_if(index_item == NULL);
-
- next_letter = _convert_char_to_string(next_app_info->pkg_label[0]);
- ret_if(next_letter == NULL);
-
- letter = elm_index_item_letter_get(index_item);
- if (!letter) {
- MGR_APP_DEBUG_ERR("letter is null.");
- goto end;
- }
-
- prev_item = elm_genlist_item_prev_get(item);
-
- if (!prev_item) {
- /* case: B-B', del:B */
- if (letter[0] == next_letter[0]) {
- _register_index_item(_index, next_letter, next_item, EINA_FALSE);
- }
- } else {
- mgr_app_app_info_t *prev_app_info = (mgr_app_app_info_t *)elm_object_item_data_get(prev_item);
- if (!prev_app_info) {
- MGR_APP_DEBUG_ERR("prev_app_info is null.");
- goto end;
- }
-
- char *prev_letter = _convert_char_to_string(prev_app_info->pkg_label[0]);
- if (!prev_letter) {
- MGR_APP_DEBUG_ERR("prev_letter is null.");
- goto end;
- }
-
- /* case: A-B'-B-B'', del:B */
- if (letter[0] == prev_letter[0]) {
- _register_index_item(_index, prev_letter, prev_item, EINA_FALSE);
-
- /* case: A-B-B'-B'', del:B */
- } else if (letter[0] == next_letter[0]) {
- _register_index_item(_index, next_letter, next_item, EINA_FALSE);
- }
-
- MGR_APP_MEM_FREE(prev_letter);
- }
- MGR_APP_MEM_FREE(next_letter);
- } else {
- /* A-B, del:B */
- MGR_APP_DEBUG("next_item is null");
- }
-
- _index_cnt--;
-
-end:
- MGR_APP_MEM_FREE(next_letter);
-
- MGR_APP_END();
-}
-
static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
{
MGR_APP_BEGIN();
ret_if(data == NULL);
struct ug_data *ugd = (struct ug_data*)data;
Evas_Object *genlist = NULL;
- Evas_Object *index = NULL;
Elm_Object_Item *item_sep = NULL;
- Evas_Object *layout = NULL;
-
Elm_Object_Item *item = NULL;
- char *letter = NULL;
- char prev_letter[MAX_BUF_SIZE] = {0, };
mgr_app_app_info_t *app_info = NULL;
itc_sep->func.state_get = NULL;
itc_sep->func.del = NULL;
- layout = mgr_app_create_layout_file(ugd->navi_bar, EDC_FILE, EDC_GROUPS);
- ret_if(NULL == layout);
-
- /* Create index */
- index = elm_index_add(layout);
- ret_if(index == NULL);
- elm_object_part_content_set(layout, "elm.swallow.content.index", index);
- evas_object_show(index);
-
-
/* add a genlist */
- genlist = elm_genlist_add(layout);
+ genlist = elm_genlist_add(ugd->navi_bar);
ret_if(genlist == NULL);
- elm_object_part_content_set(layout, "elm.swallow.content.genlist", genlist);
evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(genlist, "realized", _gl_realized, NULL);
_genlist = genlist;
- _index = index;
- _index_cnt = 0;
-
/* header border */
item_sep = elm_genlist_item_append(genlist, itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}
item = elm_genlist_item_append(genlist, itc, (void*)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
-
- /* fast scroll insertion */
- letter = _convert_char_to_string(app_info->pkg_label[0]);
- if (item && strncmp(letter, prev_letter, MAX_BUF_SIZE) != 0) {
- _register_index_item(index, letter, item, EINA_TRUE);
- strncpy(prev_letter, letter, MAX_BUF_SIZE);
- }
-
- MGR_APP_MEM_FREE(letter);
-
}
/* footer border */
if (item_sep)
elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
- evas_object_smart_callback_add(index, "delay,changed", _index_delayed_changed, index);
- evas_object_smart_callback_add(index, "changed", _index_changed, NULL);
- evas_object_smart_callback_add(index, "selected", _index_selected, NULL);
-
- elm_object_item_part_content_set(_navi_it, "elm.swallow.content", layout);
+ elm_object_item_part_content_set(_navi_it, "elm.swallow.content", genlist);
/* register pkg-mgr listener */
ret_if(ugd->pc_listen == NULL);
ret_if(data == NULL);
struct ug_data *ugd = (struct ug_data *)data;
- Evas_Object *layout = NULL;
Evas_Object *back_btn = NULL;
Evas_Object *tabbar = NULL;
- Elm_Object_Item *tool_it = NULL;
Elm_Object_Item *navi_it = NULL;
int r = 0;
MGR_APP_DEBUG_ERR("pkgmgr_get_pkg_list failed. %d", r);
}
- /* sorting by pkg_label */
- _installed_list = g_list_sort(_installed_list, _app_list_qsort_cb);
-
/* create toolbar */
tabbar = elm_toolbar_add(ugd->navi_bar);
ret_if(NULL == tabbar);