remove callback functions for CtxPopup 69/38169/1
authorJehun Lim <jehun.lim@samsung.com>
Tue, 14 Apr 2015 04:41:51 +0000 (13:41 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Tue, 14 Apr 2015 04:42:32 +0000 (13:42 +0900)
Change-Id: Ie20214094dc002f07f2e62dc0dd064f492b2e42a
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
include/view/gallery-view/SortCtxPopup.h
include/view/gallery-view/SourceCtxPopup.h
include/view/gallery-view/gallery_view.h
include/view/photo-viewer/SettingCtxPopup.h
include/view/photo-viewer/photoviewer_view.h
src/view/gallery-view/SortCtxPopup.cpp
src/view/gallery-view/SourceCtxPopup.cpp
src/view/gallery-view/gallery_view.cpp
src/view/photo-viewer/SettingCtxPopup.cpp
src/view/photo-viewer/photoviewer_view.cpp

index cca9d5f..d84b14d 100644 (file)
 #ifndef __SORT_CTXPOPUP_H__
 #define __SORT_CTXPOPUP_H__
 
-struct SGetCallbackPair;
-struct SSetCallbackPair;
-
 class CSortCtxPopup : public CCtxPopup {
 private:
-       SGetCallbackPair *GetCb;
-       SSetCallbackPair *SetCb;
+       int sort_type;
 
 protected:
        virtual void t_OnConfiguration(void);
        virtual void t_OnBtnClicked(Evas_Object *obj, void *ev);
 
 public:
-       void RegisterGetCallback(int (*cb)(void *cookie), void *cookie);
-       void RegisterSetCallback(void (*cb)(void *cookie, int sort), void *cookie);
+       void SetSortType(int type);
 };
 
 #endif
index 98e5e92..3a536b4 100644 (file)
 #ifndef __SOURCE_CTXPOPUP_H__
 #define __SOURCE_CTXPOPUP_H__
 
-struct SGetCallbackPair;
-struct SSetCallbackPair;
-
 class CSourceCtxPopup : public CCtxPopup {
 private:
-       SGetCallbackPair *GetCb;
-       SSetCallbackPair *SetCb;
+       int source_type;
 
 protected:
        virtual void t_OnConfiguration(void);
        virtual void t_OnBtnClicked(Evas_Object *obj, void *ev);
 
 public:
-       void RegisterGetCallback(int (*cb)(void *cookie), void *cookie);
-       void RegisterSetCallback(void (*cb)(void *cookie, int sort), void *cookie);
+       void SetSourceType(int type);
 };
 
 #endif
index ca064c1..94f4839 100644 (file)
@@ -76,17 +76,15 @@ protected:
        virtual void t_OnResume(void);
 
 private:
-       static void sm_CbCtxPopupSelected(void *cookie, CCtxPopup *instance, const char *text);
        static void sm_CbLayoutShown(void *cookie, CBaseLayout *pBaseLayout);
        static void sm_CbAllLayoutFocus(void *cookie);
        static void sm_CbAllLayoutSort(void *cookie, int sort);
        static void sm_CbAllLayoutHide(void *cookie);
        static void sm_CbGetSignalFromLayout(void *cookie, int sig);
        static Eina_List *sm_CbGetMediaList(void *cookie);
-       static int sm_CbSortType(void *cookie);
-       static void sm_CbSetSortType(void *cookie, int sort);
-       static int sm_CbSourceType(void *cookie);
-       static void sm_CbSetSourceType(void *cookie, int source);
+
+       static void sm_CbCtxPopupSelected(void *cookie, CCtxPopup *instance, const char *text);
+       void m_OnCtxPopupSelected(CCtxPopup *instance, const char *text);
 
 private:
        void m_DrawNotifyPopup(const char *text);
index 659d386..ef8cbc5 100644 (file)
 #ifndef __SETTING_CTXPOPUP_H__
 #define __SETTING_CTXPOPUP_H__
 
-struct SGetCallbackPair;
-struct SSetCallbackPair;
-
 class CSettingCtxPopup : public CCtxPopup {
 private:
-       SGetCallbackPair *GetCb;
-       SSetCallbackPair *SetCb;
+       int slideshow_speed;
 
 protected:
        virtual void t_OnConfiguration(void);
        virtual void t_OnBtnClicked(Evas_Object *obj, void *ev);
 
 public:
-       void RegisterGetCallback(int (*cb)(void *cookie), void *cookie);
-       void RegisterSetCallback(void (*cb)(void *cookie, int speed), void *cookie);
+       void SetSlideshowSpeed(int speed);
 };
 
 #endif
index 696502a..64e2a7b 100644 (file)
@@ -66,11 +66,8 @@ private:
        void m_OnRotateBtnClicked(Evas_Object *obj,
                        const char *emission, const char *source);
 
-       static void sm_CbSettingCtxPopupSelected(void *cookie, CCtxPopup *instance, const char *text);
-
-       static int sm_CbSlideshowSpeed(void *cookie);
-       static void sm_CbSetSlideshowSpeed(void *cookie, int speed);
-       static void sm_CbSetZoomLevel(void *cookie, int zoom_level);
+       static void sm_CbCtxPopupSelected(void *cookie, CCtxPopup *instance, const char *text);
+       void m_OnCtxPopupSelected(CCtxPopup *instance, const char *text);
 
        static Eina_Bool sm_CbTimerTooltip(void *cookie);
        Eina_Bool m_OnTimerTooltip(void);
index 1047fd9..7e1c423 100644 (file)
 #include "define.h"
 #include "menudef.h"
 
-#define BTN_ID "BTN_ID"
-
-struct SGetCallbackPair {
-       int (*cb)(void *cookie);
-       void *cookie;
-};
-
-struct SSetCallbackPair {
-       void (*cb)(void *cookie, int sort);
-       void *cookie;
-};
-
-void CSortCtxPopup::RegisterGetCallback(int (*cb)(void *cookie), void *cookie)
-{
-       GetCb = new SGetCallbackPair;
-       if (!GetCb)
-               return;
-
-       GetCb->cb = cb;
-       GetCb->cookie = cookie;
-}
-
-void CSortCtxPopup::RegisterSetCallback(void (*cb)(void *cookie, int sort), void *cookie)
-{
-       SetCb = new SSetCallbackPair;
-       if (!SetCb)
-               return;
-
-       SetCb->cb = cb;
-       SetCb->cookie = cookie;
-}
-
 void CSortCtxPopup::t_OnConfiguration(void)
 {
-       t_SetList(sorttext, SORT_TEXT_SIZE, GetCb->cb(GetCb->cookie),
+       t_SetList(sorttext, SORT_TEXT_SIZE, sort_type,
                        CCtxPopup::TOPBTN_SORT, sort_btn_id,
                        POSITION_SORT_POPUP_X, POSITION_SORT_POPUP_Y,
                        NULL,
@@ -75,25 +43,11 @@ void CSortCtxPopup::t_OnBtnClicked(Evas_Object *obj, void  *ev)
        if (!obj)
                return;
 
-       int i;
-       const char *current_id;
-
-       current_id = (const char *)evas_object_data_get(obj, BTN_ID);
-       if (!current_id)
-               return;
-
-       for (i = 0; i < SORT_TEXT_SIZE; i++) {
-               if (!strcmp(sort_btn_id[i], current_id))
-                       break;
-       }
-
-       if (i == SORT_TEXT_SIZE)
-               return;
-
-       if (i != GetCb->cb(GetCb->cookie)) {
-               SetCb->cb(SetCb->cookie, i);
-               CCtxPopup::t_OnBtnClicked(obj, ev);
-       }
-
+       CCtxPopup::t_OnBtnClicked(obj, ev);
        Destroy();
 }
+
+void CSortCtxPopup::SetSortType(int type)
+{
+       sort_type = type;
+}
index 2b6e92f..a22c581 100644 (file)
 #include "define.h"
 #include "menudef.h"
 
-#define BTN_ID "BTN_ID"
-
-struct SGetCallbackPair {
-       int (*cb)(void *cookie);
-       void *cookie;
-};
-
-struct SSetCallbackPair {
-       void (*cb)(void *cookie, int source);
-       void *cookie;
-};
-
-void CSourceCtxPopup::RegisterGetCallback(int (*cb)(void *cookie), void *cookie)
-{
-       GetCb = new SGetCallbackPair;
-       if (!GetCb)
-               return;
-
-       GetCb->cb = cb;
-       GetCb->cookie = cookie;
-}
-
-void CSourceCtxPopup::RegisterSetCallback(void (*cb)(void *cookie, int source), void *cookie)
-{
-       SetCb = new SSetCallbackPair;
-       if (!SetCb)
-               return;
-
-       SetCb->cb = cb;
-       SetCb->cookie = cookie;
-}
 void CSourceCtxPopup::t_OnConfiguration(void)
 {
-       t_SetList(sourcetext, SOURCE_TEXT_SIZE, GetCb->cb(GetCb->cookie),
+       t_SetList(sourcetext, SOURCE_TEXT_SIZE, source_type,
                        CCtxPopup::TOPBTN_SOURCE, source_btn_id,
                        POSITION_SOURCE_POPUP_X, POSITION_SOURCE_POPUP_Y,
                        NULL,
@@ -74,25 +43,11 @@ void CSourceCtxPopup::t_OnBtnClicked(Evas_Object *obj, void  *ev)
        if (!obj)
                return;
 
-       int i;
-       const char *current_id;
-
-       current_id = (const char *)evas_object_data_get(obj, BTN_ID);
-       if (!current_id)
-               return;
-
-       for (i = 0; i < SOURCE_TEXT_SIZE; i++) {
-               if (!strcmp(source_btn_id[i], current_id))
-                       break;
-       }
-
-       if (i == SOURCE_TEXT_SIZE)
-               return;
-
-       if (i != GetCb->cb(GetCb->cookie)) {
-               SetCb->cb(SetCb->cookie, i);
-               CCtxPopup::t_OnBtnClicked(obj, ev);
-       }
-
+       CCtxPopup::t_OnBtnClicked(obj, ev);
        Destroy();
 }
+
+void CSourceCtxPopup::SetSourceType(int type)
+{
+       source_type = type;
+}
index 245f92e..6f6aca6 100644 (file)
@@ -190,28 +190,47 @@ void CGalleryView::sm_CbCtxPopupSelected(void *cookie, CCtxPopup *instance, cons
        if (!root)
                return;
 
+       root->m_OnCtxPopupSelected(instance, text);
+}
+
+void CGalleryView::m_OnCtxPopupSelected(CCtxPopup *instance, const char *text)
+{
+       int i;
+
        switch (instance->Type()) {
        case CCtxPopup::TOPBTN_SORT:
-               root->m_SetBtnText(text);
-               root->m_SortLayout();
+               for (i = 0; i < SORT_TEXT_SIZE; i++) {
+                       if (!strcmp(sorttext[i], text))
+                               break;
+               }
+
+               if (i == SORT_TEXT_SIZE || i == m->sort_type)
+                       break;
+
+               m->sort_type = i;
+
+               elm_object_text_set(m->hover_btn, text);
+               m_SortLayout();
                break;
        case CCtxPopup::TOPBTN_SOURCE:
-               root->m_SetBtnText(text);
-               root->m_SourceChange();
+               for (i = 0; i < SOURCE_TEXT_SIZE; i++) {
+                       if (!strcmp(sourcetext[i], text))
+                               break;
+               }
+
+               if (i == SOURCE_TEXT_SIZE || i == m->source_type)
+                       break;
+
+               m->source_type = i;
+
+               elm_object_text_set(m->hover_btn, text);
+               m_SourceChange();
                break;
        default:
                break;
        }
 }
 
-void CGalleryView::m_SetBtnText(const char *text)
-{
-       if (!text)
-               return;
-
-       elm_object_text_set(m->hover_btn, text);
-}
-
 void CGalleryView::m_SortLayout(void)
 {
        switch (m->current_layout) {
@@ -482,34 +501,6 @@ Eina_List *CGalleryView::sm_CbGetMediaList(void *cookie)
        return m->pMediadata->MediaList();
 }
 
-int CGalleryView::sm_CbSortType(void *cookie)
-{
-       SGalleryView *m = (SGalleryView *)cookie;
-
-       return m->sort_type;
-}
-
-void CGalleryView::sm_CbSetSortType(void *cookie, int sort)
-{
-       SGalleryView *m = (SGalleryView *)cookie;
-
-       m->sort_type = sort;
-}
-
-int CGalleryView::sm_CbSourceType(void *cookie)
-{
-       SGalleryView *m = (SGalleryView *)cookie;
-
-       return m->source_type;
-}
-
-void CGalleryView::sm_CbSetSourceType(void *cookie, int source)
-{
-       SGalleryView *m = (SGalleryView *)cookie;
-
-       m->source_type = source;
-}
-
 bool CGalleryView::Create(void *data)
 {
        ASSERT(!m);
@@ -756,9 +747,8 @@ void CGalleryView::OnMouseClicked(int id, Evas_Object *obj)
                cb.onSelected = sm_CbCtxPopupSelected;
 
                CSortCtxPopup *pCtxPopup = new CSortCtxPopup;
-               pCtxPopup->RegisterGetCallback(sm_CbSortType, m);
-               pCtxPopup->RegisterSetCallback(sm_CbSetSortType, m);
                m->pCtxPopup = pCtxPopup;
+               pCtxPopup->SetSortType(m->sort_type);
                pCtxPopup->Create(m->base, &cb);
        }
                break;
@@ -769,9 +759,8 @@ void CGalleryView::OnMouseClicked(int id, Evas_Object *obj)
                cb.onSelected = sm_CbCtxPopupSelected;
 
                CSourceCtxPopup *pCtxPopup = new CSourceCtxPopup;
-               pCtxPopup->RegisterGetCallback(sm_CbSourceType, m);
-               pCtxPopup->RegisterSetCallback(sm_CbSetSourceType, m);
                m->pCtxPopup = pCtxPopup;
+               pCtxPopup->SetSourceType(m->source_type);
                pCtxPopup->Create(m->base, &cb);
        }
                break;
index 602a470..f049fac 100644 (file)
 #include "define.h"
 #include "menudef.h"
 
-#define BTN_ID "BTN_ID"
-
-struct SGetCallbackPair {
-       int (*cb)(void *cookie);
-       void *cookie;
-};
-
-struct SSetCallbackPair {
-       void (*cb)(void *cookie, int sort);
-       void *cookie;
-};
-
-void CSettingCtxPopup::RegisterGetCallback(int (*cb)(void *cookie), void *cookie)
-{
-       GetCb = new SGetCallbackPair;
-       if (!GetCb)
-               return;
-
-       GetCb->cb = cb;
-       GetCb->cookie = cookie;
-}
-
-void CSettingCtxPopup::RegisterSetCallback(void (*cb)(void *cookie, int speed), void *cookie)
-{
-       SetCb = new SSetCallbackPair;
-       if (!SetCb)
-               return;
-
-       SetCb->cb = cb;
-       SetCb->cookie = cookie;
-}
-
 void CSettingCtxPopup::t_OnConfiguration(void)
 {
-       t_SetList(speed_text, MAX_SPEED_BTNS, GetCb->cb(GetCb->cookie),
+       t_SetList(speed_text, MAX_SPEED_BTNS, slideshow_speed,
                        CCtxPopup::TOPBTN_BASE, speed_btn_id,
                        POSITION_SETTING_POPUP_X, POSITION_SETTING_POPUP_Y,
                        NULL,
@@ -72,25 +40,11 @@ void CSettingCtxPopup::t_OnBtnClicked(Evas_Object *obj, void  *ev)
        if (!obj)
                return;
 
-       int i;
-       const char *current_id;
-
-       current_id = (const char *)evas_object_data_get(obj, BTN_ID);
-       if (!current_id)
-               return;
-
-       for (i = 0; i < MAX_SPEED_BTNS; i++) {
-               if (!strcmp(speed_btn_id[i], current_id))
-                       break;
-       }
-
-       if (i == MAX_SPEED_BTNS)
-               return;
-
-       if (i != GetCb->cb(GetCb->cookie)) {
-               SetCb->cb(SetCb->cookie, i);
-               CCtxPopup::t_OnBtnClicked(obj, ev);
-       }
-
+       CCtxPopup::t_OnBtnClicked(obj, ev);
        Destroy();
 }
+
+void CSettingCtxPopup::SetSlideshowSpeed(int speed)
+{
+       slideshow_speed = speed;
+}
index 9d42ff3..d2c8ebc 100644 (file)
@@ -300,13 +300,12 @@ void CPhotoViewerView::m_OnSettingBtnClicked(Evas_Object *obj,
        elm_object_signal_emit(obj, "elm,action,highlight", "elm");
 
        CSettingCtxPopup::SCallback cb;
-       cb.cookie = m;
-       cb.onSelected = sm_CbSettingCtxPopupSelected;
+       cb.cookie = this;
+       cb.onSelected = sm_CbCtxPopupSelected;
 
        CSettingCtxPopup *pCtxPopup = new CSettingCtxPopup;
-       pCtxPopup->RegisterGetCallback(sm_CbSlideshowSpeed, m);
-       pCtxPopup->RegisterSetCallback(sm_CbSetSlideshowSpeed, m);
        m->pCtxPopup = pCtxPopup;
+       pCtxPopup->SetSlideshowSpeed(m->slideshow_speed);
        pCtxPopup->Create(m->base, &cb);
 
        m_OnTimerTooltip();
@@ -437,13 +436,30 @@ Eina_Bool CPhotoViewerView::m_OnTimerPreviewBar(void)
        return ECORE_CALLBACK_CANCEL;
 }
 
-void CPhotoViewerView::sm_CbSettingCtxPopupSelected(void *cookie,
+void CPhotoViewerView::sm_CbCtxPopupSelected(void *cookie,
                CCtxPopup *instance, const char *text)
 {
-       SPhotoViewerView *m = (SPhotoViewerView *)cookie;
-       if (!m)
+       CPhotoViewerView *root = (CPhotoViewerView *)cookie;
+       if (!root)
+               return;
+
+       root->m_OnCtxPopupSelected(instance, text);
+}
+
+void CPhotoViewerView::m_OnCtxPopupSelected(CCtxPopup *instance, const char *text)
+{
+       int i;
+
+       for (i = 0; i < MAX_SPEED_BTNS; i++) {
+               if (!strcmp(speed_text[i], text))
+                       break;
+       }
+
+       if (i == MAX_SPEED_BTNS || i == m->slideshow_speed)
                return;
 
+       m->slideshow_speed = i;
+
        if (m->slideshow_timer) {
                ecore_timer_interval_set(m->slideshow_timer,
                        slideshow_timeout[m->slideshow_speed]);
@@ -927,22 +943,6 @@ Eina_Bool CPhotoViewerView::OnFocus(void)
        return ECORE_CALLBACK_CANCEL;
 }
 
-int CPhotoViewerView::sm_CbSlideshowSpeed(void *cookie)
-{
-       SPhotoViewerView *m = (SPhotoViewerView *)cookie;
-
-       return m->slideshow_speed;
-}
-
-void CPhotoViewerView::sm_CbSetSlideshowSpeed(void *cookie, int speed)
-{
-       SPhotoViewerView *m = (SPhotoViewerView *)cookie;
-       if (!m)
-               return;
-
-       m->slideshow_speed = speed;
-}
-
 bool CPhotoViewerView::Create(void *data)
 {
        ASSERT(!m);