summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-10-17 14:26:37 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-10-17 14:27:01 +0900
commitedd6457c68176134e05a46210ea2687b5eeda15e (patch)
treeb7d9889038263a94e2f7f0147e15f31479a4ea84
parent885ee1a9e6d5c18b08936f755fe53936ea99ce59 (diff)
elm_thumb.c: Refactoring. Now thumb inherits layout.
-rw-r--r--src/lib/elm_thumb.c91
1 files changed, 15 insertions, 76 deletions
diff --git a/src/lib/elm_thumb.c b/src/lib/elm_thumb.c
index bb2ccf04a..1fa9c4c43 100644
--- a/src/lib/elm_thumb.c
+++ b/src/lib/elm_thumb.c
@@ -111,14 +111,12 @@ _thumb_ready_inform(Elm_Thumb_Smart_Data *sd,
111 (sd->view, EVAS_ASPECT_CONTROL_BOTH, aw, ah); 111 (sd->view, EVAS_ASPECT_CONTROL_BOTH, aw, ah);
112 } 112 }
113 113
114 elm_layout_content_set 114 edje_object_part_swallow(wd->resize_obj, "elm.swallow.content", sd->view);
115 (wd->resize_obj, "elm.swallow.content", sd->view);
116 eina_stringshare_replace(&(sd->thumb.file), thumb_path); 115 eina_stringshare_replace(&(sd->thumb.file), thumb_path);
117 eina_stringshare_replace(&(sd->thumb.key), thumb_key); 116 eina_stringshare_replace(&(sd->thumb.key), thumb_key);
118 elm_layout_signal_emit 117 edje_object_signal_emit
119 (wd->resize_obj, EDJE_SIGNAL_PULSE_STOP, "elm"); 118 (wd->resize_obj, EDJE_SIGNAL_PULSE_STOP, "elm");
120 elm_layout_signal_emit 119 edje_object_signal_emit(wd->resize_obj, EDJE_SIGNAL_GENERATE_STOP, "elm");
121 (wd->resize_obj, EDJE_SIGNAL_GENERATE_STOP, "elm");
122 evas_object_smart_callback_call 120 evas_object_smart_callback_call
123 (sd->obj, SIG_GENERATE_STOP, NULL); 121 (sd->obj, SIG_GENERATE_STOP, NULL);
124} 122}
@@ -301,8 +299,8 @@ _thumb_finish(Elm_Thumb_Smart_Data *sd,
301 sd->view = NULL; 299 sd->view = NULL;
302 300
303 wd = eo_data_scope_get(sd->obj, ELM_OBJ_WIDGET_CLASS); 301 wd = eo_data_scope_get(sd->obj, ELM_OBJ_WIDGET_CLASS);
304 elm_layout_signal_emit 302 edje_object_signal_emit
305 (wd->resize_obj, EDJE_SIGNAL_LOAD_ERROR, "elm"); 303 (wd->resize_obj, EDJE_SIGNAL_LOAD_ERROR, "elm");
306 evas_object_smart_callback_call 304 evas_object_smart_callback_call
307 (sd->obj, SIG_LOAD_ERROR, NULL); 305 (sd->obj, SIG_LOAD_ERROR, NULL);
308 } 306 }
@@ -310,8 +308,7 @@ _thumb_finish(Elm_Thumb_Smart_Data *sd,
310 return; 308 return;
311 309
312err: 310err:
313 elm_layout_signal_emit 311 edje_object_signal_emit(wd->resize_obj, EDJE_SIGNAL_LOAD_ERROR, "elm");
314 (wd->resize_obj, EDJE_SIGNAL_LOAD_ERROR, "elm");
315 evas_object_smart_callback_call 312 evas_object_smart_callback_call
316 (sd->obj, SIG_LOAD_ERROR, NULL); 313 (sd->obj, SIG_LOAD_ERROR, NULL);
317} 314}
@@ -358,8 +355,7 @@ _on_ethumb_thumb_error(Ethumb_Client *client __UNUSED__,
358 sd->thumb.file, sd->thumb.key ? sd->thumb.key : ""); 355 sd->thumb.file, sd->thumb.key ? sd->thumb.key : "");
359 356
360 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); 357 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
361 elm_layout_signal_emit 358 edje_object_signal_emit(wd->resize_obj, EDJE_SIGNAL_GENERATE_ERROR, "elm");
362 (wd->resize_obj, EDJE_SIGNAL_GENERATE_ERROR, "elm");
363 evas_object_smart_callback_call 359 evas_object_smart_callback_call
364 (sd->obj, SIG_GENERATE_ERROR, NULL); 360 (sd->obj, SIG_GENERATE_ERROR, NULL);
365} 361}
@@ -398,12 +394,10 @@ _thumb_start(Elm_Thumb_Smart_Data *sd)
398 if (!sd->file) return; 394 if (!sd->file) return;
399 395
400 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd); 396 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
401 elm_layout_signal_emit 397 edje_object_signal_emit(wd->resize_obj, EDJE_SIGNAL_PULSE_START, "elm");
402 (wd->resize_obj, EDJE_SIGNAL_PULSE_START, "elm"); 398 edje_object_signal_emit(wd->resize_obj, EDJE_SIGNAL_GENERATE_START, "elm");
403 elm_layout_signal_emit
404 (wd->resize_obj, EDJE_SIGNAL_GENERATE_START, "elm");
405 evas_object_smart_callback_call 399 evas_object_smart_callback_call
406 (sd->obj, SIG_GENERATE_START, NULL); 400 (sd->obj, SIG_GENERATE_START, NULL);
407 401
408 pending_request++; 402 pending_request++;
409 ethumb_client_file_set(_elm_ethumb_client, sd->file, sd->key); 403 ethumb_client_file_set(_elm_ethumb_client, sd->file, sd->key);
@@ -501,18 +495,16 @@ _elm_thumb_smart_hide(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
501 495
502 eo_do_super(obj, MY_CLASS, evas_obj_smart_hide()); 496 eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
503 497
504 evas_object_hide(wd->resize_obj);
505
506#ifdef ELM_ETHUMB 498#ifdef ELM_ETHUMB
507 if (sd->thumb.request) 499 if (sd->thumb.request)
508 { 500 {
509 ethumb_client_thumb_async_cancel(_elm_ethumb_client, sd->thumb.request); 501 ethumb_client_thumb_async_cancel(_elm_ethumb_client, sd->thumb.request);
510 sd->thumb.request = NULL; 502 sd->thumb.request = NULL;
511 503
512 elm_layout_signal_emit 504 edje_object_signal_emit
513 (wd->resize_obj, EDJE_SIGNAL_GENERATE_STOP, "elm"); 505 (wd->resize_obj, EDJE_SIGNAL_GENERATE_STOP, "elm");
514 evas_object_smart_callback_call 506 evas_object_smart_callback_call
515 (sd->obj, SIG_GENERATE_STOP, NULL); 507 (sd->obj, SIG_GENERATE_STOP, NULL);
516 } 508 }
517 509
518 if (sd->thumb.retry) 510 if (sd->thumb.retry)
@@ -553,28 +545,6 @@ _elm_thumb_dnd_cb(void *data __UNUSED__,
553 return EINA_TRUE; 545 return EINA_TRUE;
554} 546}
555 547
556static void
557_elm_thumb_smart_theme(Eo *obj, void *_pd __UNUSED__, va_list *list)
558{
559 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
560 if (ret) *ret = EINA_FALSE;
561 Eina_Bool int_ret = EINA_FALSE;
562 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
563
564 eo_do_super(obj, MY_CLASS, elm_wdg_theme(&int_ret));
565 if (!int_ret) return;
566
567 if (!elm_layout_theme_set(wd->resize_obj, "thumb", "base",
568 elm_widget_style_get(obj)))
569 {
570 if (ret) *ret = EINA_FALSE;
571 CRITICAL("Failed to set layout!");
572 return;
573 }
574
575 if (ret) *ret = EINA_TRUE;
576}
577
578EAPI Eina_Bool 548EAPI Eina_Bool
579elm_need_ethumb(void) 549elm_need_ethumb(void)
580{ 550{
@@ -598,10 +568,8 @@ _elm_thumb_smart_add(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
598 568
599 eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); 569 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
600 elm_widget_sub_object_parent_add(obj); 570 elm_widget_sub_object_parent_add(obj);
601 elm_widget_resize_object_set(obj, elm_layout_add(obj), EINA_TRUE);
602 571
603 if (!elm_layout_theme_set(wd->resize_obj, "thumb", "base", 572 if (!elm_layout_theme_set(obj, "thumb", "base", elm_widget_style_get(obj)))
604 elm_widget_style_get(obj)))
605 CRITICAL("Failed to set layout!"); 573 CRITICAL("Failed to set layout!");
606 574
607#ifdef HAVE_ELEMENTARY_ETHUMB 575#ifdef HAVE_ELEMENTARY_ETHUMB
@@ -691,31 +659,6 @@ _reload(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
691#endif 659#endif
692} 660}
693 661
694static void
695_elm_thumb_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
696{
697 Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
698 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
699 if (ret) *ret = EINA_FALSE;
700 Eina_Bool int_ret = EINA_FALSE;
701
702 eo_do_super(obj, MY_CLASS, elm_wdg_on_focus(&int_ret));
703 if (!int_ret) return;
704
705 if (elm_widget_focus_get(obj))
706 {
707 elm_layout_signal_emit(wd->resize_obj, "elm,action,focus", "elm");
708 evas_object_focus_set(wd->resize_obj, EINA_TRUE);
709 }
710 else
711 {
712 elm_layout_signal_emit(wd->resize_obj, "elm,action,unfocus", "elm");
713 evas_object_focus_set(wd->resize_obj, EINA_FALSE);
714 }
715
716 if (ret) *ret = EINA_TRUE;
717}
718
719EAPI void 662EAPI void
720elm_thumb_file_set(Evas_Object *obj, 663elm_thumb_file_set(Evas_Object *obj,
721 const char *file, 664 const char *file,
@@ -1220,15 +1163,11 @@ _class_constructor(Eo_Class *klass)
1220 const Eo_Op_Func_Description func_desc[] = { 1163 const Eo_Op_Func_Description func_desc[] = {
1221 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), 1164 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
1222 1165
1223 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_thumb_smart_theme),
1224
1225 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_thumb_smart_add), 1166 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_thumb_smart_add),
1226 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_thumb_smart_del), 1167 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_thumb_smart_del),
1227 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_thumb_smart_show), 1168 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_thumb_smart_show),
1228 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_HIDE), _elm_thumb_smart_hide), 1169 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_HIDE), _elm_thumb_smart_hide),
1229 1170
1230 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ON_FOCUS), _elm_thumb_smart_on_focus),
1231
1232 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_RELOAD), _reload), 1171 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_RELOAD), _reload),
1233 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_FILE_SET), _file_set), 1172 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_FILE_SET), _file_set),
1234 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_FILE_GET), _file_get), 1173 EO_OP_FUNC(ELM_OBJ_THUMB_ID(ELM_OBJ_THUMB_SUB_ID_FILE_GET), _file_get),
@@ -1299,5 +1238,5 @@ static const Eo_Class_Description class_desc = {
1299 NULL 1238 NULL
1300}; 1239};
1301 1240
1302EO_DEFINE_CLASS(elm_obj_thumb_class_get, &class_desc, ELM_OBJ_WIDGET_CLASS, EVAS_SMART_CLICKABLE_INTERFACE, NULL); 1241EO_DEFINE_CLASS(elm_obj_thumb_class_get, &class_desc, ELM_OBJ_LAYOUT_CLASS, EVAS_SMART_CLICKABLE_INTERFACE, NULL);
1303 1242