#include "util/listmgr.h"
#include "util/util.h"
-#define LIST_MEDIA_COND "(media_type=0 OR media_type=1) \
- AND copyright LIKE \"Unknown\""
+/*
+ FIXME
+#define LIST_MEDIA_COND "media_type=0 OR \
+ (media_type=1 AND copyright LIKE \"Unknown\")"
+*/
+#define LIST_MEDIA_COND "(media_type=0 OR media_type=1) AND copyright LIKE \"Unknown\""
#define TEXT_NOCONTENT "No Photo & Video"
-#define GRID_ITEM_X 206
-#define GRID_ITEM_Y 206
+#define GRID_PADDING 6
+#define GRID_ITEM_X (200 + GRID_PADDING)
+#define GRID_ITEM_Y (200 + GRID_PADDING)
#define GRID_NUM_ITEM 3
-#define BOX_PADDING 62
+#define BOX_PADDING (62 - GRID_PADDING)
+
+#define IMAGE_FAVORITE_ALPHA 150
struct _priv {
Evas_Object *base;
Evas_Object *layout;
+ Evas_Object *menu_btn;
layoutmgr *lmgr;
struct listmgr_data *ldata;
struct mediadata *md;
+ int cur_index;
Eina_List *media_list;
};
+static char *_grid_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ app_media *am;
+ app_media_info *info;
+ char buf[32];
+
+ if (!data)
+ return NULL;
+
+ am = data;
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ if (info->media_type != MEDIA_CONTENT_TYPE_VIDEO)
+ return NULL;
+
+ if (!strcmp(part, PART_ELM_TEXT_PLAYTIME)) {
+ util_time_string(buf, sizeof(buf),
+ info->video->duration, false);
+
+ return strdup(buf);
+ }
+
+ return NULL;
+}
+
static Evas_Object *_grid_content_get(void *data,
Evas_Object *obj, const char *part)
{
evas_object_show(image);
}
+ } else if (!strcmp(part, PART_ELM_SWALLOW_FAVORITE)) {
+ if (!info->favorite)
+ return NULL;
+
+ image = util_add_image(obj, IMAGE_THUMBNAIL_FAVORITE);
+ if (!image) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+
+ util_set_alpha_color(image, IMAGE_FAVORITE_ALPHA);
+
+ evas_object_show(image);
}
return image;
static struct grid_class _gclass = {
.item_style = STYLE_GRID_GALLERY_ITEM,
+ .text_get = _grid_text_get,
.content_get = _grid_content_get
};
vdata.list = mediadata_get_medialist(priv->md);
vdata.index = util_get_media_index(vdata.list, am);
+ priv->cur_index = vdata.index;
viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
viewmgr_push_view(VIEW_VIEWER);
static struct listmgr_data *_create_listmgr_data(struct _priv *priv)
{
struct listmgr_data *data;
+ struct grid_ops *gops;
data = calloc(1, sizeof(*data));
- if (!data) {
- _ERR("failed to allocate listmgr data");
- return NULL;
- }
+ if (!data)
+ goto err;
+
+ data->menu_btn = priv->menu_btn;
data->grid_item_x = GRID_ITEM_X;
data->grid_item_y = GRID_ITEM_Y;
data->grid_num_item = GRID_NUM_ITEM;
data->box_padding = BOX_PADDING;
- data->gclass = &_gclass;
+ gops = calloc(1, sizeof(*gops));
+ if (!gops)
+ goto err;
+
+ gops->gclass = &_gclass;
+ gops->selected_cb = _grid_selected_cb;
+ gops->ops_data = priv;
- data->grid_selected_cb = _grid_selected_cb;
- data->cb_data = priv;
+ data->gops = gops;
return data;
+
+err:
+ _ERR("failed to allocate memory");
+ return NULL;
}
-static void _update_list_area(struct _priv *priv)
+static void _update_content_info(struct _priv *priv)
+{
+ int photo, video;
+ char buf[128];
+
+ photo = mediadata_get_media_count(priv->md, E_MEDIA_PHOTO);
+ video = mediadata_get_media_count(priv->md, E_MEDIA_VIDEO);
+
+ if (photo < 0 || video < 0) {
+ _ERR("failed to get media count");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%d Photos, %d Videos", photo, video);
+
+ elm_object_part_text_set(priv->layout, PART_CONTENT_INFO, buf);
+}
+
+static void _update_content_list(struct _priv *priv)
{
Eina_List *list;
return;
}
- if (!listmgr_update_list_area(priv->listmgr, list))
+ if (!listmgr_update_content_list(priv->listmgr, list))
_ERR("failed to update list area");
priv->media_list = list;
+
+ _update_content_info(priv);
}
static bool _create(layoutmgr *lmgr, void *data)
return false;
}
+ if (!data) {
+ _ERR("invalid argument");
+ return false;
+ }
+
priv = calloc(1, sizeof(*priv));
if (!priv) {
_ERR("failed to allocate priv");
return false;
}
+ priv->menu_btn = (Evas_Object *)data;
+
base = layoutmgr_get_base(lmgr);
if (!base) {
_ERR("failed to get base object");
mediadata_destroy(priv->md);
listmgr_destroy(priv->listmgr);
+ free(priv->ldata->gops);
free(priv->ldata);
evas_object_del(priv->layout);
static void _update(void *layout_data, int update_type, void *data)
{
+ struct view_update_data *vdata;
struct _priv *priv;
+ bool update;
if (!layout_data) {
_ERR("failed to get layout data");
}
priv = layout_data;
+ vdata = data;
+
+ switch (update_type) {
+ case UPDATE_CONTENT:
+ _update_content_list(priv);
+ break;
+ case UPDATE_FOCUS:
+ if (!vdata) {
+ _ERR("invalid argument");
+ return;
+ }
- _update_list_area(priv);
+ if (priv->cur_index != vdata->index)
+ update = true;
+ else
+ update = false;
+
+ listmgr_focus_content_list(priv->listmgr, vdata->index, update);
+
+ break;
+ case UPDATE_RESUME:
+ listmgr_focus_content_list(priv->listmgr,
+ priv->cur_index, false);
+ break;
+ default:
+ break;
+ }
}
static layout_class _lclass = {