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