remove unused codes
[framework/uifw/cbhm.git] / src / clipdrawer.c
1 #include "common.h"
2 #include "cbhm_main.h"
3 #include "storage.h"
4 #include "xcnphandler.h"
5 #include "clipdrawer.h"
6
7 #define DELETE_ICON_PATH "/usr/share/cbhm/icons/05_delete.png"
8 #define IM      "/usr/share/cbhm/icons/"
9 static const char *g_images_path[] = {
10         IM"cbhm_default_img.png",
11 };
12 #define N_IMAGES (1)
13
14 #define GRID_ITEM_SPACE_W 6
15 #define GRID_ITEM_SINGLE_W 185
16 #define GRID_ITEM_SINGLE_H 161
17 #define GRID_ITEM_W (GRID_ITEM_SINGLE_W+(GRID_ITEM_SPACE_W*2))
18 #define GRID_ITEM_H (GRID_ITEM_SINGLE_H)
19 #define GRID_IMAGE_LIMIT_W 91
20 #define GRID_IMAGE_LIMIT_H 113
21
22 #define ANIM_DURATION 30 // 1 seconds
23 #define ANIM_FLOPS (0.5/30)
24
25 // gic should live at gengrid callback functions
26 Elm_Gengrid_Item_Class gic;
27 static Ecore_Timer *anim_timer = NULL;
28
29 typedef struct tag_griditem
30 {
31         int itype;
32         Elm_Gengrid_Item *item;
33         const char *ipathdata;
34         Eina_Strbuf *istrdata;
35         Evas_Object *delbtn;
36         Evas_Object *ilayout;
37 } griditem_t;
38
39 const char* clipdrawer_get_plain_string_from_escaped(char *escstr)
40 {
41         /* TODO : is it should be here? besides, remove dependency for entry */
42         /* NOTE : return string should be freed */
43         return elm_entry_markup_to_utf8(escstr);
44 }
45
46 static void _grid_del_response_cb(void *data, Evas_Object *obj, void *event_info)
47 {
48         Elm_Gengrid_Item *it = (Elm_Gengrid_Item *)data;
49         evas_object_del(obj);
50
51         if((int)event_info == ELM_POPUP_RESPONSE_OK)
52         {
53                 struct appdata *ad = g_get_main_appdata();
54                 elm_gengrid_item_del(it);
55                 ad->hicount--;
56                 if (ad->hicount < 0)
57                 {
58                         int cnt = 0;
59                         Elm_Gengrid_Item *trail = elm_gengrid_first_item_get(ad->hig);
60                         while(trail)
61                         {
62                                 cnt++;
63                                 elm_gengrid_item_next_get(trail);
64                         }
65                         ad->hicount = cnt;
66                         DTRACE("ERR: cbhm history cnt < 0, gengrid item cnt: %d\n", cnt);
67                 }
68         }
69 }
70
71 static void _grid_click_delete(void *data, Evas_Object *obj, void *event_info)
72 {
73         struct appdata *ad = data;
74 }
75
76 static void
77 _grid_item_ly_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
78 {
79         struct appdata *ad = g_get_main_appdata();
80
81         if (ad->anim_status != STATUS_NONE)
82                 return;
83
84         Elm_Gengrid_Item *sgobj = NULL;
85         sgobj = elm_gengrid_selected_item_get(ad->hig);
86         griditem_t *ti = NULL;
87         ti = elm_gengrid_item_data_get(sgobj);
88
89         #define EDJE_DELBTN_PART_PREFIX "delbtn"
90         if (strncmp(source, EDJE_DELBTN_PART_PREFIX, strlen(EDJE_DELBTN_PART_PREFIX)))
91         {
92                 if (!sgobj || !ti)
93                 {
94                         DTRACE("ERR: cbhm can't get the selected image\n");
95                         return;
96                 }
97
98                 elm_gengrid_item_selected_set(sgobj, EINA_FALSE);
99
100                 if (ti->itype == GI_TEXT)
101                 {
102                         char *p = strdup(eina_strbuf_string_get(ti->istrdata));
103
104                         elm_selection_set(1, obj, /*ELM_SEL_FORMAT_TEXT*/1, p);
105                 }
106                 else //if (ti->itype == GI_IMAGE)
107                 {
108                         if (!clipdrawer_paste_textonly_get(ad))
109                         {
110                                 int len = strlen(ti->ipathdata);
111                                 char *p = malloc(len + 10);
112                                 snprintf(p,len+10, "file:///%s", ti->ipathdata);
113
114                                 elm_selection_set(/*secondary*/1,obj,/*ELM_SEL_FORMAT_IMAGE*/4,p);
115                         }
116                         else
117                         {
118                                 DTRACE("ERR: cbhm image paste mode is false\n");
119                         }
120                 }
121
122                 return;
123         }
124
125         if (!sgobj)
126         {
127                 DTRACE("ERR: cbhm can't get the selected item\n");
128                 return;
129         }
130
131         elm_gengrid_item_selected_set(sgobj, EINA_FALSE);
132
133         Evas_Object *popup = elm_popup_add(ad->win_main);
134         elm_popup_timeout_set(popup, 5);
135         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
136         elm_popup_desc_set(popup, "Are you sure delete this?");
137         elm_popup_buttons_add(popup, 2,
138                                                   "Yes", ELM_POPUP_RESPONSE_OK,
139                                                   "No", ELM_POPUP_RESPONSE_CANCEL,
140                                                   NULL);
141         evas_object_smart_callback_add(popup, "response", _grid_del_response_cb, sgobj);
142         evas_object_show(popup);
143 }
144
145 Evas_Object* _grid_icon_get(const void *data, Evas_Object *obj, const char *part)
146 {
147         griditem_t *ti = (griditem_t *)data;
148
149         if (!strcmp(part, "elm.swallow.icon"))
150         {
151                 if (ti->itype == GI_TEXT)
152                 {
153                         Evas_Object *layout = elm_layout_add (obj);
154                         elm_layout_theme_set(layout, "gengrid", "widestyle", "horizontal_layout");
155                         edje_object_signal_callback_add(elm_layout_edje_get(layout), 
156                                                                                         "mouse,up,1", "*", _grid_item_ly_clicked, data);
157                         Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(obj));
158                         evas_object_resize(rect, GRID_ITEM_W, GRID_ITEM_H);
159                         evas_object_color_set(rect, 242, 233, 183, 255);
160                         evas_object_show(rect);
161                         elm_layout_content_set(layout, "elm.swallow.icon", rect);
162
163                         // FIXME: add string length check
164                         Evas_Object *ientry = elm_scrolled_entry_add(obj);
165                         evas_object_size_hint_weight_set(ientry, 0, 0);
166                         Eina_Strbuf *strent = NULL;
167                         char *strdata = eina_strbuf_string_get(ti->istrdata);
168                         int i, skipflag, strcnt;
169                         
170                         strent = eina_strbuf_new();
171                         skipflag = 0;
172                         strcnt = 0;
173                         for (i = 0; i < eina_strbuf_length_get(ti->istrdata); i++)
174                         {
175                                 switch (strdata[i])
176                                 {
177                                         case '>':
178                                                 skipflag = 0;
179                                                 break;
180                                         case '<':
181                                                 skipflag = 1;
182                                                 break;
183                                         default:
184                                                 if (!skipflag)
185                                                         strcnt++;
186                                                 break;
187                                 }
188                                 if (strcnt > 100)
189                                         break;
190                         }
191                         eina_strbuf_append_n(strent, strdata, i);
192                         eina_strbuf_replace_all(strent, " absize=240x180 ", " absize=52x39 ");
193                         if (strcnt > 100)
194                                 eina_strbuf_append(strent, "...");
195                         eina_strbuf_prepend(strent, "<font_size=18>");
196
197                         elm_scrolled_entry_entry_set(ientry, eina_strbuf_string_get(strent));
198                         elm_scrolled_entry_editable_set(ientry, EINA_FALSE);
199                         elm_scrolled_entry_context_menu_disabled_set(ientry, EINA_TRUE);
200                         evas_object_show(ientry);
201                         elm_layout_content_set(layout, "elm.swallow.inner", ientry);
202
203                         eina_strbuf_free(strent);
204
205                         return layout;
206                 }
207                 else// if (ti->itype == GI_IMAGE)
208                 {
209                         Evas_Object *layout = elm_layout_add (obj);
210                         elm_layout_theme_set(layout, "gengrid", "widestyle", "horizontal_layout");
211                         edje_object_signal_callback_add(elm_layout_edje_get(layout), 
212                                                                                         "mouse,up,1", "*", _grid_item_ly_clicked, data);
213
214                         Evas_Object *sicon;
215                         sicon = evas_object_image_add(evas_object_evas_get(obj));
216                         evas_object_image_load_size_set(sicon, GRID_ITEM_SINGLE_W, GRID_ITEM_SINGLE_H);
217                         evas_object_image_file_set(sicon, ti->ipathdata, NULL);
218                         evas_object_image_fill_set(sicon, 0, 0, GRID_ITEM_SINGLE_W, GRID_ITEM_SINGLE_H);
219                         evas_object_resize(sicon, GRID_ITEM_SINGLE_W, GRID_ITEM_SINGLE_H);
220                         elm_layout_content_set(layout, "elm.swallow.icon", sicon);
221
222                         struct appdata *ad = g_get_main_appdata();
223                         
224                         if (!clipdrawer_paste_textonly_get(ad))
225                         {
226                                 edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,hide,delbtn", "elm");
227                                 Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(obj));
228                                 evas_object_color_set(rect, 0, 0, 0, 200);
229                                 evas_object_show(rect);
230                                 elm_layout_content_set(layout, "elm.swallow.cover", rect);
231                         }
232
233                         ti->ilayout = layout;
234                         return layout;
235                 }
236         }
237
238         return NULL;
239 }
240
241 static void _grid_longpress(void *data, Evas_Object *obj, void *event_info)
242 {
243         struct appdata *ad = data;
244 }
245
246 static void _grid_click_paste(void *data, Evas_Object *obj, void *event_info)
247 {
248         struct appdata *ad = data;
249         if (ad->anim_status != STATUS_NONE)
250                 return;
251
252         Elm_Gengrid_Item *sgobj = NULL;
253         sgobj = elm_gengrid_selected_item_get(ad->hig);
254         griditem_t *ti = NULL;
255         ti = elm_gengrid_item_data_get(sgobj);
256 }
257
258 void _grid_del(const void *data, Evas_Object *obj)
259 {
260         griditem_t *ti = (griditem_t *)data;
261         if (ti->itype == GI_TEXT)
262                 eina_strbuf_free(ti->istrdata);
263         else
264                 eina_stringshare_del(ti->ipathdata);
265         free(ti);
266 }
267
268 char* clipdrawer_get_item_data(void *data, int pos)
269 {
270         struct appdata *ad = data;
271         griditem_t *ti = NULL;
272         griditem_t *newgi = NULL;
273         int count = 0;
274
275         if (pos < 0 || pos > ad->hicount)
276                 return NULL;
277
278         Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
279         while (item)    
280         {
281                 ti = elm_gengrid_item_data_get(item);
282                 if (count == pos)
283                 {
284                         if (!ti)
285                                 break;
286                         if (ti->itype == GI_TEXT)
287                                 return (char*)eina_strbuf_string_get(ti->istrdata);
288                         else
289                                 return ti->ipathdata;
290                 }
291                 count++;
292                 item = elm_gengrid_item_next_get(item);      
293         }
294
295         return NULL;
296 }
297
298 // FIXME: how to remove calling g_get_main_appdata()? 
299 //        it's mainly used at 'clipdrawer_image_item'
300 int clipdrawer_add_item(char *idata, int type)
301 {
302         struct appdata *ad = g_get_main_appdata();
303         griditem_t *newgi = NULL;
304
305         newgi = malloc(sizeof(griditem_t));
306         newgi->itype = type;
307
308         fprintf(stderr, "## add - %d : %s\n", newgi->itype, idata);
309         if (type == GI_TEXT)
310         {
311                 newgi->istrdata = eina_strbuf_new();
312                 eina_strbuf_append(newgi->istrdata, idata);
313         }
314         else //if (type == GI_IMAGE)
315         {
316                 Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
317                 griditem_t *ti = NULL;
318
319                 if (!check_regular_file(idata))
320                 {
321                         DTRACE("Error : it isn't normal file = %s\n", idata);
322                         return -1;
323                 }
324
325                 while (item)    
326                 {
327                         ti = elm_gengrid_item_data_get(item);
328                         if ((ti->itype == type) && !strcmp(ti->ipathdata, idata))
329                         {
330                                 DTRACE("Error : duplicated file path = %s\n", idata);
331                                 return -1;
332                         }
333                         item = elm_gengrid_item_next_get(item);      
334                 }
335                 newgi->ipathdata = eina_stringshare_add(idata);
336         }
337
338         if (ad->hicount >= HISTORY_QUEUE_MAX_ITEMS)
339         {
340                 ad->hicount--;
341                 // FIXME: add routine that is removing its elements
342                 elm_gengrid_item_del(elm_gengrid_last_item_get(ad->hig));
343         }
344
345         ad->hicount++;
346         newgi->item = elm_gengrid_item_prepend(ad->hig, &gic, newgi, NULL, NULL);
347
348         return TRUE;
349 }
350
351 static void
352 clipdrawer_ly_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
353 {
354         struct appdata *ad = data;
355
356         if (ad->anim_status != STATUS_NONE)
357                 return;
358
359         #define EDJE_CLOSE_PART_PREFIX "background/close"
360         if (!strncmp(source, EDJE_CLOSE_PART_PREFIX, strlen(EDJE_CLOSE_PART_PREFIX)))
361         {
362                 clipdrawer_lower_view(ad);
363         }
364 }
365
366 void set_rotation_to_clipdrawer(void *data, int angle)
367 {
368         struct appdata *ad = data;
369         double wh, wy;
370         int wposx, wwidth;
371
372         if (angle == 180) // reverse
373         {
374                 wh = (1.0*CLIPDRAWER_HEIGHT/SCREEN_HEIGHT)*ad->root_h;
375                 wy = 0;
376                 wwidth = ad->root_w;
377                 wposx = CLIPDRAWER_POS_X;
378         }
379         else if (angle == 90) // right rotate
380         {
381                 wh = (1.0*CLIPDRAWER_HEIGHT_LANDSCAPE/SCREEN_WIDTH)*ad->root_w;
382                 wy = (1.0*CLIPDRAWER_POS_X/SCREEN_WIDTH)*ad->root_w;
383                 wwidth = ad->root_h;
384                 wposx = CLIPDRAWER_WIDTH-CLIPDRAWER_HEIGHT_LANDSCAPE;
385         }
386         else if (angle == -90) // left rotate
387         {
388                 wh = (1.0*CLIPDRAWER_HEIGHT_LANDSCAPE/SCREEN_WIDTH)*ad->root_w;
389                 wy = (1.0*CLIPDRAWER_POS_X/SCREEN_WIDTH)*ad->root_w;
390                 wwidth = ad->root_h;
391                 wposx = CLIPDRAWER_POS_X;
392         }
393         else // angle == 0
394         {
395                 wh = (1.0*CLIPDRAWER_HEIGHT/SCREEN_HEIGHT)*ad->root_h;
396                 wy = (1.0*CLIPDRAWER_POS_Y/SCREEN_HEIGHT)*ad->root_h;
397                 wwidth = ad->root_w;
398                 wposx = CLIPDRAWER_POS_X;
399         }
400
401         evas_object_resize(ad->win_main, wwidth, (int)wh);
402         evas_object_move(ad->win_main, wposx, (int)wy);
403 }
404
405 int clipdrawer_init(void *data)
406 {
407         struct appdata *ad = data;
408         double cdy, cdw;
409
410         ad->windowshow = EINA_FALSE;
411         ad->hicount = 0;
412         ad->pastetextonly = EINA_TRUE;
413         ad->anim_status = STATUS_NONE;
414         ad->anim_count = 0;
415
416         // for elm_check
417         elm_theme_extension_add(NULL, APP_EDJ_FILE);
418
419         set_rotation_to_clipdrawer(ad, get_rotation_degree());
420
421         edje_object_signal_callback_add(elm_layout_edje_get(ad->ly_main), 
422                                                                         "mouse,up,1", "*", clipdrawer_ly_clicked, ad);
423
424         ad->hig = NULL;
425         ad->hig = elm_gengrid_add(ad->win_main);
426         elm_layout_content_set(ad->ly_main, "historyitems", ad->hig);
427         elm_gengrid_item_size_set(ad->hig, GRID_ITEM_W+2, GRID_ITEM_H);
428         elm_gengrid_align_set(ad->hig, 0.5, 0.5);
429         elm_gengrid_horizontal_set(ad->hig, EINA_TRUE);
430         elm_gengrid_bounce_set(ad->hig, EINA_TRUE, EINA_FALSE);
431         elm_gengrid_multi_select_set(ad->hig, EINA_FALSE);
432         evas_object_smart_callback_add(ad->hig, "selected", _grid_click_paste, ad);
433 //      evas_object_smart_callback_add(ad->hig, "longpressed", _grid_longpress, ad);
434         evas_object_size_hint_weight_set(ad->hig, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
435
436         elm_gengrid_clear(ad->hig);
437
438         gic.item_style = "default_grid";
439         gic.func.label_get = NULL;
440         gic.func.icon_get = _grid_icon_get;
441         gic.func.state_get = NULL;
442         gic.func.del = _grid_del;
443
444         int i;
445         griditem_t *newgi;
446
447         for (i = 0; i < N_IMAGES; i++)
448         {
449                 clipdrawer_add_item(g_images_path[0], GI_IMAGE);
450         }
451
452         clipdrawer_add_item("clipboard history", GI_TEXT);
453
454         evas_object_show (ad->hig);
455
456 // for debugging, calc history pos
457 /*
458    Evas_Coord x, y, w, h;
459    Evas_Coord vx, vy, vw, vh;
460
461    edje_object_part_geometry_get(elm_layout_edje_get(ad->ly_main),"imagehistory/list",&x,&y,&w,&h);
462    evas_object_geometry_get (ad->hig, &vx,&vy,&vw,&vh);
463    fprintf(stderr, "## x = %d, y = %d, w = %d, h = %d\n", x, y, w, h);
464    fprintf(stderr, "## vx = %d, vy = %d, vw = %d, vh = %d\n", vx, vy, vw, vh);
465 */
466
467 //      if (get_item_counts() != 0)
468 //              clipdrawer_update_contents(ad);
469
470         return 0;
471 }
472
473 int clipdrawer_create_view(void *data)
474 {
475         struct appdata *ad = data;
476
477         clipdrawer_init(ad);
478
479         // for debug
480         // at starting, showing app view
481         //clipdrawer_activate_view(ad);
482
483         return 0;
484 }
485
486 Eina_Bool _get_anim_pos(void *data, int *sp, int *ep)
487 {
488         if (!sp || !ep)
489                 return EINA_FALSE;
490
491         struct appdata *ad = data;
492         int angle = get_rotation_degree();
493         int anim_start, anim_end, delta;
494
495         if (angle == 180) // reverse
496         {
497                 anim_start = (int)(((double)CLIPDRAWER_HEIGHT/SCREEN_HEIGHT)*ad->root_h);
498                 anim_start = ad->root_h - anim_start;
499                 anim_start = -anim_start;
500                 anim_end = 0;
501         }
502         else if (angle == 90) // right rotate
503         {
504                 anim_start = ad->root_w;
505                 anim_end = (int)(((double)CLIPDRAWER_HEIGHT_LANDSCAPE/SCREEN_WIDTH)*ad->root_w);
506                 anim_end = anim_start-anim_end;
507         }
508         else if (angle == -90) // left rotate
509         {
510                 anim_start = (int)(((double)CLIPDRAWER_HEIGHT_LANDSCAPE/SCREEN_WIDTH)*ad->root_w);
511                 anim_start = ad->root_w-anim_start;
512                 anim_start = -anim_start;
513                 anim_end = 0;
514         }
515         else // angle == 0
516         {
517                 anim_start = ad->root_h;
518                 anim_end = (int)(((double)CLIPDRAWER_HEIGHT/SCREEN_HEIGHT)*ad->root_h);
519                 anim_end = anim_start-anim_end;
520         }
521
522         *sp = anim_start;
523         *ep = anim_end;
524         return EINA_TRUE;
525 }
526
527 Eina_Bool _do_anim_delta_pos(void *data, int sp, int ep, int ac, int *dp)
528 {
529         if (!dp)
530                 return EINA_FALSE;
531
532         struct appdata *ad = data;
533         int angle = get_rotation_degree();
534         int delta;
535         double posprop;
536         posprop = 1.0*ac/ANIM_DURATION;
537
538         if (angle == 180) // reverse
539         {
540                 delta = (int)((ep-sp)*posprop);
541                 evas_object_move(ad->win_main, 0, sp+delta);
542         }
543         else if (angle == 90) // right rotate
544         {
545                 delta = (int)((ep-sp)*posprop);
546                 evas_object_move(ad->win_main, sp+delta, 0);
547         }
548         else if (angle == -90) // left rotate
549         {
550                 delta = (int)((ep-sp)*posprop);
551                 evas_object_move(ad->win_main, sp+delta, 0);
552         }
553         else // angle == 0
554         {
555                 delta = (int)((sp-ep)*posprop);
556                 evas_object_move(ad->win_main, 0, sp-delta);
557         }
558         
559         *dp = delta;
560
561         return EINA_TRUE;
562 }
563
564 static void stop_animation(void *data)
565 {
566         struct appdata *ad = data;
567
568         ad->anim_status = STATUS_NONE;
569         if (anim_timer)
570         {
571                 ecore_timer_del(anim_timer);
572                 anim_timer = NULL;
573         }
574 }
575
576 Eina_Bool anim_pos_calc_cb(void *data)
577 {
578         struct appdata *ad = data;
579
580         int anim_start, anim_end, delta;
581
582         _get_anim_pos(ad, &anim_start, &anim_end);
583
584         if (ad->anim_status == SHOW_ANIM)
585         {
586                 if (ad->anim_count > ANIM_DURATION)
587                 {
588                         ad->anim_count = ANIM_DURATION;
589                         stop_animation(data);
590                         return EINA_FALSE;
591                 }
592                 _do_anim_delta_pos(ad, anim_start, anim_end, ad->anim_count, &delta);
593                 ad->anim_count++;
594         }
595         else if (ad->anim_status == HIDE_ANIM)
596         {
597                 if (ad->anim_count < 0)
598                 {
599                         ad->anim_count = 0;
600                         evas_object_hide(ad->win_main);
601                         elm_win_lower(ad->win_main);
602                         unset_transient_for(ad);
603                         stop_animation(data);
604                         return EINA_FALSE;
605                 }
606                 _do_anim_delta_pos(ad, anim_start, anim_end, ad->anim_count, &delta);
607                 ad->anim_count--;
608         }
609         else
610         {
611                 stop_animation(data);
612                 return EINA_FALSE;
613         }
614
615         return EINA_TRUE;
616 }
617
618 Eina_Bool clipdrawer_anim_effect(void *data, anim_status_t atype)
619 {
620         struct appdata *ad = data;
621
622         if (atype == ad->anim_status)
623         {
624                 DTRACE("Warning: Animation effect is already in progress. \n");
625                 return EINA_FALSE;
626         }
627
628         ad->anim_status = atype;
629
630         if (anim_timer)
631                 ecore_timer_del(anim_timer);
632
633         anim_timer = ecore_timer_add(ANIM_FLOPS, anim_pos_calc_cb, ad);
634
635         return EINA_TRUE;
636 }
637
638 void clipdrawer_activate_view(void *data)
639 {
640         struct appdata *ad = data;
641
642         if (ad->win_main)
643         {
644                 set_transient_for(ad);
645                 evas_object_show(ad->win_main);
646                 elm_win_activate(ad->win_main);
647                 if (clipdrawer_anim_effect(ad, SHOW_ANIM))
648                         ad->windowshow = EINA_TRUE;
649         }
650 }
651
652 void clipdrawer_lower_view(void *data)
653 {
654         struct appdata *ad = data;
655         
656         if (ad->win_main && ad->windowshow)
657         {
658                 if (clipdrawer_anim_effect(ad, HIDE_ANIM))
659                         ad->windowshow = EINA_FALSE;
660         }
661 }
662
663 void _change_gengrid_paste_textonly_mode(void *data)
664 {
665         struct appdata *ad = data;
666
667         Elm_Gengrid_Item *item;
668         griditem_t *ti = NULL;
669
670         if (clipdrawer_paste_textonly_get(ad))
671         { // textonly paste mode
672                 Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
673
674                 while (item)    
675                 {
676                         ti = elm_gengrid_item_data_get(item);
677                         if ((ti->itype == GI_IMAGE) && (ti->ilayout))
678                         {
679                                 edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,hide,delbtn", "elm");
680                                 Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(ad->hig));
681                                 evas_object_color_set(rect, 0, 0, 0, 200);
682                                 evas_object_show(rect);
683                                 elm_layout_content_set(ti->ilayout, "elm.swallow.cover", rect);
684                         }
685                         item = elm_gengrid_item_next_get(item);
686                 }
687         }
688         else
689         { // text+image paste mode
690                 Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
691
692                 while (item)    
693                 {
694                         ti = elm_gengrid_item_data_get(item);
695                         if ((ti->itype == GI_IMAGE) && (ti->ilayout))
696                         {
697                                 edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,show,delbtn", "elm");
698                                 Evas_Object *rect = elm_layout_content_unset(ti->ilayout, "elm.swallow.cover");
699                                 evas_object_hide(rect);
700                                 evas_object_del(rect);
701                         }
702                         item = elm_gengrid_item_next_get(item);      
703                 }
704         }
705 }
706
707 void clipdrawer_paste_textonly_set(void *data, Eina_Bool textonly)
708 {
709         struct appdata *ad = data;
710         textonly = !!textonly;
711         if (ad->pastetextonly != textonly)
712                 ad->pastetextonly = textonly;
713         DTRACE("paste textonly mode = %d\n", textonly);
714
715         _change_gengrid_paste_textonly_mode(ad);
716 }
717
718 Eina_Bool clipdrawer_paste_textonly_get(void *data)
719 {
720         struct appdata *ad = data;
721         return ad->pastetextonly;
722 }