timeout_handler: add function for enable/disable handler 39/43439/1
authorMinkyu Kang <mk7.kang@samsung.com>
Thu, 9 Jul 2015 08:38:58 +0000 (17:38 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Thu, 9 Jul 2015 08:38:58 +0000 (17:38 +0900)
Change-Id: I45dc8113dd9e5b8d8f336476c1753966849910a0
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
include/util/timeout_handler.h
src/util/timeout_handler.c
src/view/viewer.c

index 29dd6e1..5cd0aab 100644 (file)
@@ -29,4 +29,6 @@ void timeout_handler_fini(struct timeout_handler *handle);
 
 void timeout_handler_reset(struct timeout_handler *handle);
 
+void timeout_handler_enable(struct timeout_handler *handle, bool enable);
+
 #endif
index 4d73de1..dce195f 100644 (file)
@@ -31,6 +31,7 @@ struct timeout_handler {
        void *timeout_data;
 
        double timeout;
+       bool enable;
 };
 
 static Eina_Bool _timer_cb(void *data)
@@ -42,6 +43,9 @@ static Eina_Bool _timer_cb(void *data)
 
        handle = data;
 
+       if (!handle->enable)
+               return ECORE_CALLBACK_CANCEL;
+
        handle->timeout_cb(handle->timeout_data, 0, NULL);
        handle->timer = NULL;
 
@@ -57,6 +61,9 @@ static Eina_Bool _event_occured(void *data, int type, void *event)
 
        handle = data;
 
+       if (!handle->enable)
+               return ECORE_CALLBACK_PASS_ON;
+
        handle->event_cb(handle->event_data, type, event);
 
        timeout_handler_reset(handle);
@@ -64,6 +71,16 @@ static Eina_Bool _event_occured(void *data, int type, void *event)
        return ECORE_CALLBACK_PASS_ON;
 }
 
+void timeout_handler_enable(struct timeout_handler *handle, bool enable)
+{
+       handle->enable = enable;
+
+       if (!enable) {
+               ecore_timer_del(handle->timer);
+               handle->timer = NULL;
+       }
+}
+
 void timeout_handler_reset(struct timeout_handler *handle)
 {
        if (!handle) {
@@ -117,6 +134,7 @@ struct timeout_handler *timeout_handler_init(double timeout,
        handle->timeout_cb = timeout_cb;
        handle->timeout_data = timeout_data;
        handle->timeout = timeout;
+       handle->enable = false;
 
        return handle;
 
index 8adbea9..e3a9a8a 100644 (file)
@@ -886,6 +886,7 @@ static void _show(void *view_data)
 
        _viewer_show(priv, DIR_NONE);
 
+       timeout_handler_enable(priv->timeout, true);
        timeout_handler_reset(priv->timeout);
 
        evas_object_show(priv->base);
@@ -904,6 +905,8 @@ static void _hide(void *view_data)
 
        _viewer_hide(priv);
 
+       timeout_handler_enable(priv->timeout, false);
+
        evas_object_hide(priv->base);
 }