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