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