cabef97af56c52b2bf981cdab973dd1d56bf7f08
[framework/uifw/elementary.git] / src / lib / elm_thumb.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Thumb Thumb
6  * @ingroup Elementary
7  *
8  * A thumb object is used for displaying the thumbnail of an image or video.
9  * You must have compiled Elementary with Ethumb_Client support and the DBus
10  * service must be present and auto-activated in order to have thumbnails to
11  * be generated.
12  *
13  * Signals that you can add callbacks for are:
14  *
15  * clicked - This is called when a user has clicked the thumb without dragging
16  * around.
17  *
18  * clicked,double - This is called when a user has double-clicked the thumb.
19  *
20  * press - This is called when a user has pressed down the thumb.
21  *
22  * generate,start - The thumbnail generation started.
23  *
24  * generate,stop - The generation process stopped.
25  *
26  * generate,error - The generation failed.
27  *
28  * load,error - The thumbnail image loading failed.
29  */
30
31 typedef struct _Widget_Data Widget_Data;
32
33 struct _Widget_Data
34 {
35    Evas_Object *self;
36    Evas_Object *frame;
37    Evas_Object *view;
38    const char *file;
39    const char *key;
40    struct
41      {
42         int id;
43         const char *file;
44         const char *key;
45      } thumb;
46    Ecore_Event_Handler *eeh;
47    Elm_Thumb_Animation_Setting anim_setting;
48    Eina_Bool on_hold : 1;
49    Eina_Bool is_video : 1;
50    Eina_Bool was_video : 1;
51    Eina_Bool edit : 1;
52
53 };
54
55 static const char *widtype = NULL;
56
57 static const char SIG_CLICKED[] = "clicked";
58 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
59 static const char SIG_GENERATE_ERROR[] = "generate,error";
60 static const char SIG_GENERATE_START[] = "generate,start";
61 static const char SIG_GENERATE_STOP[] = "generate,stop";
62 static const char SIG_LOAD_ERROR[] = "load,error";
63 static const char SIG_PRESS[]= "press";
64 static const Evas_Smart_Cb_Description _signals[] = {
65   {SIG_CLICKED, ""},
66   {SIG_CLICKED_DOUBLE, ""},
67   {SIG_GENERATE_ERROR, ""},
68   {SIG_GENERATE_START, ""},
69   {SIG_GENERATE_STOP, ""},
70   {SIG_LOAD_ERROR, ""},
71   {SIG_PRESS, ""},
72   {NULL, NULL}
73 };
74
75 static const char EDJE_SIGNAL_GENERATE_START[] = "elm,thumb,generate,start";
76 static const char EDJE_SIGNAL_GENERATE_STOP[] = "elm,thumb,generate,stop";
77 static const char EDJE_SIGNAL_GENERATE_ERROR[] = "elm,thumb,generate,error";
78 static const char EDJE_SIGNAL_LOAD_ERROR[] = "elm,thumb,load,error";
79 static const char EDJE_SIGNAL_PULSE_START[] = "elm,state,pulse,start";
80 static const char EDJE_SIGNAL_PULSE_STOP[] = "elm,state,pulse,stop";
81
82 struct _Ethumb_Client *_elm_ethumb_client = NULL;
83 Eina_Bool _elm_ethumb_connected = EINA_FALSE;
84
85 EAPI int ELM_ECORE_EVENT_ETHUMB_CONNECT = 0;
86
87 static void
88 _del_hook(Evas_Object *obj)
89 {
90    Widget_Data *wd = elm_widget_data_get(obj);
91
92 #ifdef HAVE_ELEMENTARY_ETHUMB
93    if (wd->thumb.id >= 0)
94      ethumb_client_generate_cancel(_elm_ethumb_client, wd->thumb.id,
95                                    NULL, NULL, NULL);
96 #endif
97
98    eina_stringshare_del(wd->file);
99    eina_stringshare_del(wd->key);
100    if (wd->eeh) ecore_event_handler_del(wd->eeh);
101    free(wd);
102 }
103
104 static void
105 _theme_hook(Evas_Object *obj)
106 {
107    Widget_Data *wd = elm_widget_data_get(obj);
108    _elm_theme_object_set(obj, wd->frame, "thumb", "base", elm_widget_style_get(obj));
109 }
110
111 #ifdef HAVE_ELEMENTARY_ETHUMB
112 static void
113 _mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
114 {
115    Widget_Data *wd = data;
116    Evas_Event_Mouse_Down *ev = event_info;
117    if (ev->button != 1)
118      return;
119    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
120      wd->on_hold = EINA_TRUE;
121    else
122      wd->on_hold = EINA_FALSE;
123    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
124      evas_object_smart_callback_call(wd->self, SIG_CLICKED_DOUBLE, NULL);
125    else
126      evas_object_smart_callback_call(wd->self, SIG_PRESS, NULL);
127 }
128
129 static void
130 _mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
131 {
132
133    Widget_Data *wd = data;
134    Evas_Event_Mouse_Up *ev = event_info;
135    if (ev->button != 1)
136      return;
137    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
138      wd->on_hold = EINA_TRUE;
139    else
140      wd->on_hold = EINA_FALSE;
141    if (!wd->on_hold)
142      evas_object_smart_callback_call(wd->self, SIG_CLICKED, NULL);
143    wd->on_hold = EINA_FALSE;
144 }
145
146 static void
147 _finished_thumb(Widget_Data *wd, const char *thumb_path, const char *thumb_key)
148 {
149    Eina_Bool new_view = EINA_FALSE;
150    int r;
151    Evas_Coord mw, mh;
152    Evas *evas;
153
154    evas = evas_object_evas_get(wd->self);
155    if ((wd->view) && (wd->is_video ^ wd->was_video))
156      {
157         evas_object_del(wd->view);
158         wd->view = NULL;
159      }
160    wd->was_video = wd->is_video;
161
162    if ((wd->is_video) &&
163        (ethumb_client_format_get(_elm_ethumb_client) == ETHUMB_THUMB_EET))
164      {
165         if (!wd->view)
166           {
167              wd->view = edje_object_add(evas);
168              if (!wd->view)
169                {
170                   ERR("could not create edje object");
171                   goto err;
172                }
173              new_view = EINA_TRUE;
174           }
175
176         if (!edje_object_file_set(wd->view, thumb_path, "movie/thumb"))
177           {
178              ERR("could not set file=%s key=%s for %s", thumb_path, thumb_key,
179                  wd->file);
180              goto view_err;
181           }
182      }
183    else
184      {
185         if (!wd->view)
186           {
187              wd->view = evas_object_image_filled_add(evas);
188              if (!wd->view)
189                {
190                   ERR("could not create image object");
191                   goto err;
192                }
193              new_view = EINA_TRUE;
194           }
195
196         evas_object_image_file_set(wd->view, thumb_path, thumb_key);
197         r = evas_object_image_load_error_get(wd->view);
198         if (r != EVAS_LOAD_ERROR_NONE)
199           {
200              ERR("%s: %s", thumb_path, evas_load_error_str(r));
201              goto view_err;
202           }
203      }
204
205    if (new_view) elm_widget_sub_object_add(wd->self, wd->view);
206    edje_object_part_swallow(wd->frame, "elm.swallow.content", wd->view);
207    edje_object_size_min_get(wd->frame, &mw, &mh);
208    edje_object_size_min_restricted_calc(wd->frame, &mw, &mh, mw, mh);
209    evas_object_size_hint_min_set(wd->self, mw, mh);
210    eina_stringshare_replace(&(wd->thumb.file), thumb_path);
211    eina_stringshare_replace(&(wd->thumb.key), thumb_key);
212    edje_object_signal_emit(wd->frame, EDJE_SIGNAL_GENERATE_STOP, "elm");
213    evas_object_smart_callback_call(wd->self, SIG_GENERATE_STOP, NULL);
214    return;
215
216 view_err:
217    evas_object_del(wd->view);
218    wd->view = NULL;
219 err:
220    edje_object_signal_emit(wd->frame, EDJE_SIGNAL_LOAD_ERROR, "elm");
221    evas_object_smart_callback_call(wd->self, SIG_LOAD_ERROR, NULL);
222 }
223
224 static void
225 _finished_thumb_cb(void *data, Ethumb_Client *c __UNUSED__, int id, const char *file, const char *key, const char *thumb_path, const char *thumb_key, Eina_Bool success)
226 {
227    Widget_Data *wd = data;
228
229    EINA_SAFETY_ON_FALSE_RETURN(wd->thumb.id == id);
230    wd->thumb.id = -1;
231
232    edje_object_signal_emit(wd->frame, EDJE_SIGNAL_PULSE_STOP, "elm");
233
234    if (success)
235      {
236         _finished_thumb(wd, thumb_path, thumb_key);
237         return;
238      }
239
240    ERR("could not generate thumbnail for %s (key: %s)", file, key ? key : "");
241    edje_object_signal_emit(wd->frame, EDJE_SIGNAL_GENERATE_ERROR, "elm");
242    evas_object_smart_callback_call(wd->self, SIG_GENERATE_ERROR, NULL);
243 }
244
245 static void
246 _thumb_apply(Widget_Data *wd)
247 {
248    ethumb_client_file_set(_elm_ethumb_client, wd->file, wd->key);
249    if (ethumb_client_thumb_exists(_elm_ethumb_client))
250      {
251         const char *thumb_path, *thumb_key;
252         wd->thumb.id = -1;
253         ethumb_client_thumb_path_get(_elm_ethumb_client, &thumb_path,
254                                      &thumb_key);
255         _finished_thumb(wd, thumb_path, thumb_key);
256         return;
257      }
258    else if ((wd->thumb.id = ethumb_client_generate
259              (_elm_ethumb_client, _finished_thumb_cb, wd, NULL)) != -1)
260      {
261         edje_object_signal_emit(wd->frame, EDJE_SIGNAL_PULSE_START,
262                                 "elm");
263         edje_object_signal_emit(wd->frame, EDJE_SIGNAL_GENERATE_START,
264                                 "elm");
265         evas_object_smart_callback_call(wd->self, SIG_GENERATE_START, NULL);
266      }
267    else
268      {
269         wd->thumb.id = -1;
270         edje_object_signal_emit(wd->frame, EDJE_SIGNAL_GENERATE_ERROR,
271                                 "elm");
272         evas_object_smart_callback_call(wd->self, SIG_GENERATE_ERROR, NULL);
273      }
274 }
275
276 static Eina_Bool
277 _thumb_apply_cb(void *data, int type __UNUSED__, void *ev __UNUSED__)
278 {
279    _thumb_apply(data);
280    return ECORE_CALLBACK_RENEW;
281 }
282
283 static void
284 _thumb_show(Widget_Data *wd)
285 {
286    evas_object_show(wd->frame);
287
288    if (elm_thumb_ethumb_client_connected())
289      {
290         _thumb_apply(wd);
291         return;
292      }
293
294    if (!wd->eeh)
295      wd->eeh = ecore_event_handler_add(ELM_ECORE_EVENT_ETHUMB_CONNECT,
296                                        _thumb_apply_cb, wd);
297 }
298
299 static void
300 _thumb_show_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
301 {
302    _thumb_show(data);
303 }
304
305 static void
306 _thumb_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
307 {
308    Widget_Data *wd = data;
309
310    evas_object_hide(wd->frame);
311
312    if (wd->thumb.id >= 0)
313      {
314         ethumb_client_generate_cancel
315           (_elm_ethumb_client, wd->thumb.id, NULL, NULL, NULL);
316         wd->thumb.id = -1;
317
318         edje_object_signal_emit(wd->frame, EDJE_SIGNAL_GENERATE_STOP, "elm");
319         evas_object_smart_callback_call(wd->self, SIG_GENERATE_STOP, NULL);
320      }
321
322    if (wd->eeh)
323      {
324         ecore_event_handler_del(wd->eeh);
325         wd->eeh = NULL;
326      }
327 }
328
329 #endif
330
331 #ifdef ELM_ETHUMB
332 static int _elm_need_ethumb = 0;
333
334 static void _on_die_cb(void *, Ethumb_Client *);
335
336 static void
337 _connect_cb(void *data __UNUSED__, Ethumb_Client *c, Eina_Bool success)
338 {
339    if (success)
340      {
341         ethumb_client_on_server_die_callback_set(c, _on_die_cb, NULL, NULL);
342         _elm_ethumb_connected = EINA_TRUE;
343         ecore_event_add(ELM_ECORE_EVENT_ETHUMB_CONNECT, NULL, NULL, NULL);
344      }
345    else
346      _elm_ethumb_client = NULL;
347 }
348
349 static void
350 _on_die_cb(void *data __UNUSED__, Ethumb_Client *c __UNUSED__)
351 {
352    ethumb_client_disconnect(_elm_ethumb_client);
353    _elm_ethumb_client = NULL;
354    _elm_ethumb_connected = EINA_FALSE;
355    _elm_ethumb_client = ethumb_client_connect(_connect_cb, NULL, NULL);
356 }
357 #endif
358
359 void
360 _elm_unneed_ethumb(void)
361 {
362 #ifdef ELM_ETHUMB
363    if (-- _elm_need_ethumb != 0) return;
364
365    ethumb_client_disconnect(_elm_ethumb_client);
366    _elm_ethumb_client = NULL;
367    ethumb_client_shutdown();
368    ELM_ECORE_EVENT_ETHUMB_CONNECT = 0;
369 #endif
370 }
371
372 static Eina_Bool
373 _elm_thumb_dropcb(void *data __UNUSED__, Evas_Object *o, Elm_Selection_Data *drop)
374 {
375    if ((!o) || (!drop) || (!drop->data)) return EINA_FALSE;
376    elm_thumb_file_set(o, drop->data, NULL);
377    return EINA_TRUE;
378 }
379
380 /**
381  * This must be called before any other function that handle with
382  * elm_thumb objects or ethumb_client instances.
383  *
384  * @ingroup Thumb
385  */
386 EAPI Eina_Bool
387 elm_need_ethumb(void)
388 {
389 #ifdef ELM_ETHUMB
390    if (_elm_need_ethumb ++ != 0) return;
391    ELM_ECORE_EVENT_ETHUMB_CONNECT = ecore_event_type_new();
392    ethumb_client_init();
393    _elm_ethumb_client = ethumb_client_connect(_connect_cb, NULL, NULL);
394 #endif
395 }
396
397 /**
398  * Add a new thumb object to the parent.
399  *
400  * @param parent The parent object.
401  * @return The new object or NULL if it cannot be created.
402  *
403  * @see elm_thumb_file_set()
404  * @see elm_thumb_ethumb_client_get()
405  *
406  * @ingroup Thumb
407  */
408 EAPI Evas_Object *
409 elm_thumb_add(Evas_Object *parent)
410 {
411    Evas *evas;
412    Widget_Data *wd;
413    Evas_Object *obj;
414    Evas_Coord minw, minh;
415
416    wd = ELM_NEW(Widget_Data);
417    evas = evas_object_evas_get(parent);
418    obj = elm_widget_add(evas);
419    ELM_SET_WIDTYPE(widtype, "thumb");
420    elm_widget_type_set(obj, "thumb");
421    elm_widget_sub_object_add(parent, obj);
422    elm_widget_data_set(obj, wd);
423    elm_widget_del_hook_set(obj, _del_hook);
424    elm_widget_theme_hook_set(obj, _theme_hook);
425
426    wd->frame = edje_object_add(evas);
427    _elm_theme_object_set(obj, wd->frame, "thumb", "base", "default");
428    elm_widget_resize_object_set(obj, wd->frame);
429
430    edje_object_size_min_calc(obj, &minw, &minh);
431    evas_object_size_hint_min_set(obj, minw, minh);
432
433    wd->self = obj;
434    wd->view = NULL;
435    wd->file = NULL;
436    wd->key = NULL;
437    wd->eeh = NULL;
438    wd->thumb.id = -1;
439    wd->on_hold = EINA_FALSE;
440    wd->is_video = EINA_FALSE;
441    wd->was_video = EINA_FALSE;
442
443 #ifdef HAVE_ELEMENTARY_ETHUMB
444    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
445                                   _mouse_down_cb, wd);
446    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
447                                   _mouse_up_cb, wd);
448    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW,
449                                   _thumb_show_cb, wd);
450    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
451                                   _thumb_hide_cb, wd);
452 #endif
453
454    // TODO: convert Elementary to subclassing of Evas_Smart_Class
455    // TODO: and save some bytes, making descriptions per-class and not instance!
456    evas_object_smart_callbacks_descriptions_set(obj, _signals);
457    return obj;
458 }
459
460 /**
461  * Set the file that will be used as thumbnail.
462  *
463  * The file can be an image or a video (in that case, acceptable extensions are:
464  * avi, mp4, ogv, mov, mpg and wmv). To start the video animation, use the
465  * function elm_thumb_animate().
466  *
467  * @param obj The thumb object.
468  * @param file The path to file that will be used as thumb.
469  * @param key The key used in case of an EET file.
470  *
471  * @see elm_thumb_file_get()
472  * @see elm_thumb_animate()
473  *
474  * @ingroup Thumb
475  */
476 EAPI void
477 elm_thumb_file_set(Evas_Object *obj, const char *file, const char *key)
478 {
479    ELM_CHECK_WIDTYPE(obj, widtype);
480    Eina_Bool file_replaced, key_replaced;
481    Widget_Data *wd = elm_widget_data_get(obj);
482
483    file_replaced = eina_stringshare_replace(&(wd->file), file);
484    key_replaced = eina_stringshare_replace(&(wd->key), key);
485
486    if (file_replaced)
487      {
488         int prefix_size;
489         const char **ext, *ptr;
490         static const char *extensions[] = { ".avi", ".mp4", ".ogv", ".mov",
491                                             ".mpg", ".wmv", NULL };
492
493         prefix_size = eina_stringshare_strlen(wd->file) - 4;
494         if (prefix_size >= 0)
495           {
496              ptr = wd->file + prefix_size;
497              wd->is_video = EINA_FALSE;
498              for (ext = extensions; *ext; ext++)
499                if (!strcasecmp(ptr, *ext))
500                  {
501                     wd->is_video = EINA_TRUE;
502                     break;
503                  }
504           }
505      }
506
507    eina_stringshare_replace(&(wd->thumb.file), NULL);
508    eina_stringshare_replace(&(wd->thumb.key), NULL);
509
510 #ifdef HAVE_ELEMENTARY_ETHUMB
511    if ((file_replaced || key_replaced) && evas_object_visible_get(obj))
512      _thumb_show(wd);
513 #endif
514 }
515
516 /**
517  * Get the image or video path and key used to generate the thumbnail.
518  *
519  * @param obj The thumb object.
520  * @param file Pointer to filename.
521  * @param key Pointer to key.
522  *
523  * @see elm_thumb_file_set()
524  * @see elm_thumb_path_get()
525  * @see elm_thumb_animate()
526  *
527  * @ingroup Thumb
528  */
529 EAPI void
530 elm_thumb_file_get(const Evas_Object *obj, const char **file, const char **key)
531 {
532    ELM_CHECK_WIDTYPE(obj, widtype);
533    Widget_Data *wd = elm_widget_data_get(obj);
534    if (file)
535      *file = wd->file;
536    if (key)
537      *key = wd->key;
538 }
539
540 /**
541  * Get the path and key to the image or video generated by ethumb.
542  *
543  * One just need to make sure that the thumbnail was generated before getting
544  * its path; otherwise, the path will be NULL. One way to do that is by asking
545  * for the path when/after the "generate,stop" smart callback is called.
546  *
547  * @param obj The thumb object.
548  * @param file Pointer to thumb path.
549  * @param key Pointer to thumb key.
550  *
551  * @see elm_thumb_file_get()
552  *
553  * @ingroup Thumb
554  */
555 EAPI void
556 elm_thumb_path_get(const Evas_Object *obj, const char **file, const char **key)
557 {
558    ELM_CHECK_WIDTYPE(obj, widtype);
559    Widget_Data *wd = elm_widget_data_get(obj);
560    if (file)
561      *file = wd->thumb.file;
562    if (key)
563      *key = wd->thumb.key;
564 }
565
566 /**
567  * Set the animation state for the thumb object. If its content is an animated
568  * video, you may start/stop the animation or tell it to play continuously and
569  * looping.
570  *
571  * @param obj The thumb object.
572  * @param setting The animation setting.
573  *
574  * @see elm_thumb_file_set()
575  *
576  * @ingroup Thumb
577  */
578 EAPI void
579 elm_thumb_animate_set(Evas_Object *obj, Elm_Thumb_Animation_Setting setting)
580 {
581    ELM_CHECK_WIDTYPE(obj, widtype);
582    Widget_Data *wd = elm_widget_data_get(obj);
583
584    if (setting < ELM_THUMB_ANIMATION_START ||
585        setting >= ELM_THUMB_ANIMATION_LAST)
586      {
587         return;
588      }
589
590    wd->anim_setting = setting;
591    if (setting == ELM_THUMB_ANIMATION_LOOP)
592      edje_object_signal_emit(wd->view, "animate_loop", "");
593    else if (setting == ELM_THUMB_ANIMATION_START)
594      edje_object_signal_emit(wd->view, "animate", "");
595    else if (setting == ELM_THUMB_ANIMATION_STOP)
596      edje_object_signal_emit(wd->view, "animate_stop", "");
597 }
598
599 /**
600  * Get the animation state for the thumb object.
601  *
602  * @param obj The thumb object.
603  * @return getting The animation setting or @c ELM_THUMB_ANIMATION_LAST,
604  * on errors.
605  *
606  * @see elm_thumb_file_get()
607  *
608  * @ingroup Thumb
609  */
610 EAPI Elm_Thumb_Animation_Setting
611 elm_thumb_animate_get(const Evas_Object *obj)
612 {
613    ELM_CHECK_WIDTYPE(obj, widtype) ELM_THUMB_ANIMATION_LAST;
614    Widget_Data *wd = elm_widget_data_get(obj);
615
616    return wd->anim_setting;
617 }
618
619 /**
620  * Get the ethumb_client handle so custom configuration can be made.
621  * This must be called before the objects are created to be sure no object is
622  * visible and no generation started.
623  *
624  * @return Ethumb_Client instance or NULL.
625  *
626  * Example of usage:
627  *
628  * @code
629  * #include <Elementary.h>
630  * #ifndef ELM_LIB_QUICKLAUNCH
631  * EAPI int
632  * elm_main(int argc, char **argv)
633  * {
634  *    Ethumb_Client *client;
635  *
636  *    elm_need_ethumb();
637  *
638  *    // ... your code
639  *
640  *    client = elm_thumb_ethumb_client_get();
641  *    if (!client)
642  *      {
643  *         ERR("could not get ethumb_client");
644  *         return 1;
645  *      }
646  *    ethumb_client_size_set(client, 100, 100);
647  *    ethumb_client_crop_align_set(client, 0.5, 0.5);
648  *    // ... your code
649  *
650  *    // Create elm_thumb objects here
651  *
652  *    elm_run();
653  *    elm_shutdown();
654  *    return 0;
655  * }
656  * #endif
657  * ELM_MAIN()
658  * @endcode
659  *
660  * @ingroup Thumb
661  */
662 EAPI struct _Ethumb_Client *
663 elm_thumb_ethumb_client_get(void)
664 {
665    return _elm_ethumb_client;
666 }
667
668 /**
669  * Get the ethumb_client connection state.
670  *
671  * @return EINA_TRUE if the client is connected to the server or
672  *         EINA_FALSE otherwise.
673  */
674 EAPI Eina_Bool
675 elm_thumb_ethumb_client_connected(void)
676 {
677    return _elm_ethumb_connected;
678 }
679
680
681 EAPI Eina_Bool
682 elm_thumb_editable_set(Evas_Object *obj, Eina_Bool edit)
683 {
684    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
685    Widget_Data *wd = elm_widget_data_get(obj);
686
687    if (!wd) return EINA_FALSE;
688    edit = !!edit;
689    if (wd->edit == edit) return EINA_TRUE;
690
691    wd->edit = edit;
692    if (wd->edit)
693       elm_drop_target_add(obj, ELM_SEL_FORMAT_IMAGE,
694                             _elm_thumb_dropcb, obj);
695    else
696       elm_drop_target_del(obj);
697
698    return EINA_TRUE;
699 }
700
701 EAPI Eina_Bool
702 elm_thumb_editable_get(Evas_Object *obj)
703 {
704    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
705    Widget_Data *wd = elm_widget_data_get(obj);
706    if (!wd) return EINA_FALSE;
707    return wd->edit;
708 }
709
710 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/