+#include <Elementary.h>
+#include <AppCommon.h>
+#include <BaseView.h>
+#include <ViewMgr.h>
+#include <BaseLayout.h>
+#include <LayoutMgr.h>
+
+#include "dbg.h"
+#include "define.h"
+#include "FileGrid.h"
+
+#include <CtxPopup.h>
+#include "FbBaseView.h"
+#include "FbMusicLayout.h"
+
+
+struct SFbMusicLayout {
+ Evas_Object *eoWin;
+ Evas_Object *eoBase;
+ CFileGrid *pFileGrid;
+
+ CLayoutMgr *pLayoutMgr;
+ CViewMgr *pViewMgr;
+
+ bool updateFlag;
+};
+
+
+void CFbMusicLayout::sm_CbUpdateEmptyFocusSequence(void* cookie)
+{
+ _DBG();
+ CFbBaseView *pfbBaseView = NULL;
+ Evas_Object *eoBase = (Evas_Object*)cookie;
+
+ if (!eoBase)
+ return;
+
+ pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA);
+ ASSERT(pfbBaseView);
+ pfbBaseView->UpdateEmptyFocusSequence();
+}
+
+
+void CFbMusicLayout::sm_CbUpdatedGrid(void* cookie)
+{
+ _DBG();
+ CFbBaseView *pfbBaseView = NULL;
+ Evas_Object *eoBase = (Evas_Object*)cookie;
+ if (!eoBase)
+ return;
+
+ pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA);
+ ASSERT(pfbBaseView);
+ pfbBaseView->UpdatedGrid();
+}
+
+
+void CFbMusicLayout::sm_CbUnsetFocus(void* cookie)
+{
+ _DBG();
+ CFbBaseView *pfbBaseView = NULL;
+ Evas_Object *eoBase = (Evas_Object*)cookie;
+ if (eoBase) {
+ pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA);
+ ASSERT(pfbBaseView);
+ pfbBaseView->UnsetFocus();
+ }
+}
+
+
+void CFbMusicLayout::sm_CbLinkApp(void* cookie, int type, int source_type, char *path)
+{
+ _DBG();
+ CFbBaseView *pfbBaseView = NULL;
+ Evas_Object *eoBase = (Evas_Object*)cookie;
+ if (eoBase)
+ {
+ pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA);
+ ASSERT(pfbBaseView);
+ pfbBaseView->CbLinkApp(type, source_type, path);
+ }
+}
+
+
+bool CFbMusicLayout::t_CreateFileGrid(Evas_Object *layout)
+{
+ m->pFileGrid = new CFileGrid;
+ if (!m->pFileGrid)
+ return false;
+
+ CFileGrid::SCallback cb;
+ cb.cbUpdateEmptyFocusSequence = sm_CbUpdateEmptyFocusSequence;
+ cb.cbUpdatedGrid = sm_CbUpdatedGrid;
+ cb.cbUnsetFocus = sm_CbUnsetFocus;
+ cb.cbLinkApp = sm_CbLinkApp;
+ cb.cookie = m->eoBase;
+ if (!m->pFileGrid->Create(m->eoWin, layout, &cb)) {
+ _DBG("Fail to create FileGrid");
+ delete m->pFileGrid;
+ m->pFileGrid = NULL;
+ return false;
+ }
+ return true;
+}
+
+
+void CFbMusicLayout::t_DestroyFileGrid(void)
+{
+ if (!m->pFileGrid)
+ return;
+
+ m->pFileGrid->Destroy();
+ delete m->pFileGrid;
+ m->pFileGrid = NULL;
+}
+
+
+void CFbMusicLayout::t_OnShow(void)
+{
+ elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT);
+ elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, Layout());
+ m->pFileGrid->Update(m->updateFlag);
+ m->updateFlag = false; // set default
+ CBaseLayout::t_OnShow();
+}
+
+
+bool CFbMusicLayout::Create(CLayoutMgr *mgr, void *data)
+{
+ ASSERT(!m);
+ ASSERT(mgr);
+
+ Evas_Object* layout = NULL;
+
+ _CREATE_BEGIN{
+ _CHECK(m = new SFbMusicLayout)
+ _CHECK(m->pLayoutMgr = mgr)
+ _CHECK(m->pViewMgr = CViewMgr::GetInstance())
+ _CHECK(m->eoBase = m->pLayoutMgr->Base())
+ _CHECK(m->eoWin = m->pViewMgr->Window())
+ _CHECK(layout = elm_layout_add(m->eoBase))
+ _CHECK(elm_layout_file_set(layout, EDJEFILE, FB_MUSIC_LAYOUT))
+ _CHECK(t_CreateFileGrid(layout))
+ _COMMAND{
+ m->updateFlag = false;
+ elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT);
+ elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout);
+ }
+ _CHECK(CBaseLayout::Create(layout))
+
+ _WHEN_SUCCESS{}
+
+ _CHECK_FAIL{ CBaseLayout::Destroy(); }
+ _CHECK_FAIL{ t_DestroyFileGrid(); }
+ _CHECK_FAIL{ /* elm_layout_file_set */ }
+ _CHECK_FAIL{ /* elm_layout_add */ }
+ _CHECK_FAIL{ /* m->pViewMgr->Window()*/ }
+ _CHECK_FAIL{ /* m->pLayoutMgr->Base() */ }
+ _CHECK_FAIL{ /* CViewMgr::GetInstace() */ }
+ _CHECK_FAIL{ /* m->pLayoutMgr = mgr */ }
+ _CHECK_FAIL{ delete m; m = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
+
+ return true;
+}
+
+
+void CFbMusicLayout::Destroy(void)
+{
+ ASSERT(m);
+
+ CBaseLayout::Destroy();
+ t_DestroyFileGrid();
+ delete m;
+ m = NULL;
+}
+
+
+void CFbMusicLayout::SetFocus(Eina_Bool flag)
+{
+ ASSERT(m);
+ _DBG();
+
+ m->pFileGrid->SetFocus(flag);
+}
+
+
+void CFbMusicLayout::Action(void)
+{
+ ASSERT(m);
+
+ return m->pFileGrid->Action();
+}
+
+
+void CFbMusicLayout::SetUpdateFlag(bool flag)
+{
+ ASSERT(m);
+
+ m->updateFlag = flag;
+}