#ifndef __AIR_MEDIAHUB_VIEW_BASE_H__
#define __AIR_MEDIAHUB_VIEW_BASE_H__
+/* view */
#define VIEW_BASE "VIEW_BASE"
+/* group */
#define GRP_BASE_VIEW "group.base_view"
+#define GRP_LIST_ITEM "group.list_item"
+/* part */
#define PART_TITLE "part.title"
#define PART_MENU_AREA "part.menu_area"
#define PART_THUMBNAIL_AREA "part.thumbnail_area"
#define PART_BOTTOM_AREA "part.bottom_area"
-#define STYLE_MENU_BTN "base_btn_menu"
+#define PART_ITEM_TITLE "part.item_title"
+#define PART_ITEM_CONTENT "part.item_content"
+
+/* images */
+#define IMAGE_THUMBNAIL_PLAY IMAGEDIR"/ic_thumbnail_play.png"
+
+/* style */
+#define STYLE_BTN_MENU "base_btn_menu"
+#define STYLE_BTN_INDEX "base_btn_index"
#endif /* __AIR_MEDIAHUB_VIEW_BASE_H__ */
*/
#include <Elementary.h>
+#include <media_content.h>
#include <app_debug.h>
+#include <app_media.h>
+#include <gridmgr.h>
#include <layoutmgr.h>
#include "define.h"
+#include "data/mediadata.h"
+#include "util/listmgr.h"
+#include "util/util.h"
+
+#define LIST_MEDIA_COND "media_type=0 OR media_type=1"
+
+#define TEXT_NOCONTENT "No Photo & Video"
+
+#define GRID_ITEM_X 206
+#define GRID_ITEM_Y 206
+#define GRID_NUM_ITEM 3
+
+#define BOX_PADDING 62
struct _priv {
Evas_Object *base;
Evas_Object *layout;
layoutmgr *lmgr;
+
+ struct listmgr *listmgr;
+
+ struct mediadata *md;
+
+ Eina_List *media_list;
+};
+
+static Evas_Object *_grid_content_get(void *data,
+ Evas_Object *obj, const char *part)
+{
+ Evas_Object *image;
+ app_media *am;
+ app_media_info *info;
+
+ if (!data)
+ return NULL;
+
+ am = data;
+ info = app_media_get_info(am);
+ if (!info) {
+ _ERR("failed to get media info");
+ return NULL;
+ }
+
+ image = NULL;
+ if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ image = util_add_image(obj, info->thumbnail_path);
+ if (!image) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+
+ evas_object_show(image);
+ } else if (!strcmp(part, PART_ELM_SWALLOW_VIDEO)) {
+ if (info->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+ image = util_add_image(obj, IMAGE_THUMBNAIL_PLAY);
+ if (!image) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+
+ evas_object_show(image);
+ }
+ }
+
+ return image;
+}
+
+static struct grid_class _gclass = {
+ .item_style = STYLE_GRID_GALLERY_ITEM,
+ .content_get = _grid_content_get
};
+static struct listmgr_data *_create_listmgr_data(void)
+{
+ struct listmgr_data *data;
+
+ data = calloc(1, sizeof(*data));
+ if (!data) {
+ _ERR("failed to allocate listmgr data");
+ return NULL;
+ }
+
+ 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;
+
+ return data;
+}
+
+static void _update_list_area(struct _priv *priv)
+{
+ Eina_List *list;
+
+ if (priv->media_list)
+ return;
+
+ list = mediadata_get_list(priv->md, E_LIST_DATE);
+ if (!list) {
+ elm_object_part_text_set(priv->layout,
+ PART_NOCONTENT, TEXT_NOCONTENT);
+ return;
+ }
+
+ if (!listmgr_update_list_area(priv->listmgr, list))
+ _ERR("failed to update list area");
+
+ priv->media_list = list;
+}
+
static bool _create(layoutmgr *lmgr, void *data)
{
+ struct listmgr *listmgr;
+ struct listmgr_data *ldata;
+ struct mediadata *md;
struct _priv *priv;
Evas_Object *base, *layout;
base = layoutmgr_get_base(lmgr);
if (!base) {
_ERR("failed to get base object");
- free(priv);
- return false;
+ goto err;
}
layout = elm_layout_add(base);
if (!layout) {
_ERR("failed to create layout");
- free(priv);
- return false;
+ goto err;
}
if (!elm_layout_file_set(layout, EDJEFILE, GRP_GALLERY_LAYOUT)) {
_ERR("failed to set layout file");
- evas_object_del(layout);
- free(priv);
+ goto err2;
+ }
+
+ ldata = _create_listmgr_data();
+ if (!ldata) {
+ _ERR("failed to create listmgr data");
+ goto err2;
+ }
+
+ listmgr = listmgr_create(layout, (void *)ldata);
+ if (!listmgr) {
+ _ERR("failed to create listmgr");
+ goto err3;
+ }
+
+ md = mediadata_create(LIST_MEDIA_COND, E_SOURCE_ALL, E_SORT_DATE);
+ if (!md) {
+ _ERR("failed to create mediadata");
+ listmgr_destroy(listmgr);
+ goto err3;
}
priv->base = base;
priv->layout = layout;
priv->lmgr = lmgr;
+ priv->listmgr = listmgr;
+ priv->md = md;
layoutmgr_set_layout_data(lmgr, LAYOUT_GALLERY, priv);
+ if (!listmgr_draw_list_area(listmgr)) {
+ _ERR("failed to draw list area");
+ mediadata_destroy(md);
+ listmgr_destroy(listmgr);
+ goto err3;
+ }
+
return true;
+
+err3:
+ free(ldata);
+err2:
+ evas_object_del(layout);
+err:
+ free(priv);
+ return false;
}
static void _destroy(void *layout_data)
priv = layout_data;
+ mediadata_free_list(priv->media_list);
+ mediadata_destroy(priv->md);
+
+ listmgr_destroy(priv->listmgr);
+
evas_object_del(priv->layout);
free(priv);
}
static void _update(void *layout_data, int update_type, void *data)
{
+ struct _priv *priv;
+
+ if (!layout_data) {
+ _ERR("failed to get layout data");
+ return;
+ }
+
+ priv = layout_data;
+
+ _update_list_area(priv);
}
static layout_class _lclass = {
#include "define.h"
#include "data/mediadata.h"
#include "util/listmgr.h"
+#include "util/util.h"
#define LIST_MEDIA_COND "media_type=1 AND copyright NOT LIKE \"Unknown\""
am = data;
+ image = NULL;
if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
- image = elm_image_add(obj);
- if (!image) {
- _ERR("failed to create image object");
- return NULL;
- }
-
info = app_media_get_info(am);
if (!info) {
_ERR("failed to get media info");
return NULL;
}
- elm_image_file_set(image, info->thumbnail_path, NULL);
- elm_image_aspect_fixed_set(image, EINA_FALSE);
+ image = util_add_image(obj, info->thumbnail_path);
+ if (!image) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
evas_object_show(image);
-
- return image;
}
- return NULL;
+ return image;
}
static struct grid_class _gclass = {