9a161d0397ff2b9f8e8f287516e582e4c0902c46
[profile/tv/apps/native/filebrowser.git] / src / views / FbContextView.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #include <Elementary.h>
18 #include <Eina.h>
19 #include "dbg.h"
20 #include <AppCommon.h>
21 #include "define.h"
22 #include "common.h"
23 #include "i18n.h"
24 #include "FbContextView.h"
25 #include "Dummy/DummyContent.h"
26
27 //#define _GET_PRIV(o) evas_object_data_get(o, "CTMDATA");
28 //#define _SET_PRIV(o, data) evas_object_data_set(o, "CTMDATA", data);
29
30 #define FBR_TEXT_SIZE N_("Size")
31 #define FBR_TEXT_FORMAT N_("Format")
32 #define FBR_TEXT_OPEN N_("OPEN")
33 #define FBR_TEXT_LINK N_("Other linkable apps")
34 #define FBR_TEXT_REL N_("Other apps for this type")
35 #define EMPTY_STR ""
36 #define TOTAL_CONTEXT_BTNS 5
37 #define TABLE_MAX_COL 2
38 #define MIN_LABEL_WIDTH 103
39 #define FBR_CTXT_BTN_WPAD 26
40 #define FBR_CTXT_TABLE_WPAD 14
41 #define FBR_CTXT_TABLE_HPAD 14
42
43
44 struct SContextView {
45         Evas_Object *eoWin;
46         Evas_Object *eoBase;
47         Evas_Object *eoBtnOpen;
48         Evas_Object *rel_first[TABLE_MAX_COL];
49         Evas_Object *rel_last[TABLE_MAX_COL];
50         Evas_Object *link_first[TABLE_MAX_COL];
51         Evas_Object *link_last[TABLE_MAX_COL];
52
53         CExtNameInfo *finfo;
54
55         CDummyContent content;
56
57         SContextView() {
58                 eoWin = NULL;
59                 eoBase = NULL;
60                 eoBtnOpen = NULL;
61                 int a;
62                 for (a = 0; a < TABLE_MAX_COL; a++) {
63                         rel_first[a] = NULL;
64                         rel_last[a] = NULL;
65                         link_first[a] = NULL;
66                         link_last[a] = NULL;
67                 }
68                 finfo = NULL;
69                 pHandlerButton = new SContextView::CHandlerButton(this);
70         }
71         ~SContextView() {
72                 delete pHandlerButton;
73         }
74
75         class CHandlerButton : public CListenerMgr, IMouseMoveListener, IMouseUpListener, IKeyUpListener {
76                 SContextView *m;
77         public:
78                 CHandlerButton(SContextView *ins) : IMouseMoveListener(this), IMouseUpListener(this), IKeyUpListener(this) { m = ins; }
79
80                 virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) {
81                         if (!elm_object_focus_get(obj))
82                                 elm_object_focus_set(obj, EINA_TRUE);
83                 }
84                 virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev) {
85                         _DBG();
86                         if (m->eoBtnOpen == obj) {
87                                 _DBG();
88                                 if (strcmp(ev->keyname, KEY_ENTER) && strcmp(ev->keyname, KEY_ENTER_REMOTE))
89                                         return;
90
91                                 CViewMgr::GetInstance()->UpdateView(FBR_BASE_VIEW, NULL);
92                         }
93                         else {
94                                 _DBG();
95                                 if (strcmp(ev->keyname, KEY_ENTER) && strcmp(ev->keyname, KEY_ENTER_REMOTE))
96                                         return;
97
98                                 elm_object_signal_emit(obj, FBR_SIGNAL_CONTENT_CLICKED, FBR_CONTEXT_VIEW);
99                         }
100                 }
101                 virtual void OnMouseUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Up *ev) {
102                         _DBG();
103                         if (m->eoBtnOpen == obj) {
104                                 CViewMgr::GetInstance()->UpdateView(FBR_BASE_VIEW, NULL);
105                         }
106                         else {
107                                 elm_object_signal_emit(obj, FBR_SIGNAL_CONTENT_CLICKED, FBR_CONTEXT_VIEW);
108                         }
109                 }
110         } *pHandlerButton;
111 };
112
113
114 extern const char *typestr[];
115
116
117 void CContextView::_lbl_start_slide(Evas_Object *lbl)
118 {
119         elm_label_ellipsis_set(lbl, EINA_FALSE);
120         elm_label_slide_mode_set(lbl, ELM_LABEL_SLIDE_MODE_AUTO);
121         elm_label_slide_go(lbl);
122 }
123
124 void CContextView::_btn_focused(void *data, Evas_Object *obj, void *ev)
125 {
126         _DBG();
127         if (!obj)
128                 return;
129
130         elm_object_signal_emit(obj, FBR_SIGNAL_FOCUSED, FBR_CONTEXT_VIEW);
131
132 }
133
134 void CContextView::_btn_unfocused(void *data, Evas_Object *obj, void *ev)
135 {
136         _DBG();
137         if (!obj)
138                 return;
139
140         elm_object_signal_emit(obj, FBR_SIGNAL_UNFOCUSED, FBR_CONTEXT_VIEW);
141 }
142
143
144 bool CContextView::_add_btn_label(Evas_Object *btn, const char *txt)
145 {
146         Evas_Object *lbl;
147         char buf[MAX_LENGTH];
148
149         if (!btn || !txt)
150                 return false;
151
152         lbl = elm_label_add(btn);
153         if (!lbl) {
154                 _ERR("elm_label_add failed.");
155                 return false;
156         }
157
158         snprintf(buf, sizeof(buf),
159                         "<align=center><color=#FFFFFFFF>"
160                         "<font=%s>"
161                         "<font_size=21>%s</font_size>"
162                         "</font></color></align>", FONT_STYLE_MEDIUM, _(txt));
163         elm_object_text_set(lbl, buf);
164         elm_label_line_wrap_set(lbl, ELM_WRAP_WORD);
165         evas_object_size_hint_min_set(lbl, MIN_LABEL_WIDTH, 0);
166         elm_object_part_content_set(btn, FBR_PART_CTXT_BTNTEXT, lbl);
167
168         return true;
169 }
170
171 bool CContextView::_add_btn_icon(Evas_Object *btn, const char *icon)
172 {
173         Evas_Object *img;
174         char buf[MAX_LENGTH];
175
176         if (!btn || !icon)
177                 return false;
178
179         img = elm_image_add(btn);
180         if (!img) {
181                 _ERR("elm_image_add failed.");
182                 return false;
183         }
184
185         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, icon);
186         elm_image_file_set(img, buf, NULL);
187         elm_object_part_content_set(btn, FBR_PART_CTXT_BTNICON, img);
188
189         return true;
190 }
191
192 bool CContextView::_add_btn_info(Evas_Object *btn, const char *icon, const char *txt)
193 {
194         if (!btn || !icon || !txt)
195                 return false;
196
197         if (!_add_btn_icon(btn, icon))
198                 return false;
199
200         if (!_add_btn_label(btn, txt))
201                 return false;
202
203         return true;
204 }
205
206
207 Evas_Object *CContextView::_add_btnbox(Evas_Object *eoBase)
208 {
209         Evas_Object *box;
210
211         if (!eoBase)
212                 return NULL;
213
214         box = elm_box_add(eoBase);
215         if (!box) {
216                 _ERR(" elm_box_add failed ");
217                 return NULL;
218         }
219
220         elm_box_horizontal_set(box, EINA_TRUE);
221         elm_box_padding_set(box, FBR_CTXT_BTN_WPAD, 0);
222         elm_box_align_set(box, 0, 0.5);
223         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
224                         EVAS_HINT_EXPAND);
225
226         return box;
227 }
228
229 bool CContextView::_get_context_details(CExtNameInfo *pInfo, char **path, char **title, char *subtitle, char *subtitle2)
230 {
231         char buf[MAX_LENGTH];
232         TSize size;
233         double size_mb;
234         int type;
235
236         if (!pInfo)
237                 return false;
238
239         *title = pInfo->Name();
240         *path  = pInfo->ThumbnailPath();
241         size = pInfo->Size();
242
243         size_mb = (double)size / (1024 * 1024); /* Convert to MB */
244
245         snprintf(buf, sizeof(buf), "%s : %f MB", _(FBR_TEXT_SIZE), size_mb);
246         strcpy(subtitle, buf);
247
248         type = pInfo->Type();
249         snprintf(buf, sizeof(buf), "%s : %s", _(FBR_TEXT_FORMAT), _(typestr[type]));
250         strcpy(subtitle2, buf);
251
252         return true;
253 }
254
255 Evas_Object *CContextView::_add_rltv_ctnt(Evas_Object *obj, const char *name, const char *icon)
256 {
257         Evas_Object *ly, *img;
258         char buf[MAX_LENGTH];
259
260         if (!obj) {
261                 _ERR("Invalid argument.");
262                 return NULL;
263         }
264
265         ly = elm_layout_add(obj);
266         if (!ly) {
267                 _ERR("elm_layout_add failed.");
268                 return NULL;
269         }
270
271         elm_layout_file_set(ly, EDJEFILE, FBR_CONTEXT_APP);
272         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
273
274         img = elm_image_add(ly);
275         if (!img) {
276                 _ERR("elm_image_add failed.");
277                 evas_object_del(ly);
278                 return NULL;
279         }
280
281         if (!icon || !strcmp(icon, EMPTY_STR)) {
282                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, FBR_IMAGE_DEFAULT_APP);
283                 elm_image_file_set(img, buf, NULL);
284                 elm_image_no_scale_set(img, EINA_TRUE);
285         } else {
286                 elm_image_file_set(img, icon, NULL);
287                 elm_image_aspect_fixed_set(img, EINA_FALSE);
288         }
289
290         elm_object_part_content_set(ly, FBR_PART_CTXT_RELCTNT_ICON, img);
291         elm_object_part_text_set(ly, FBR_PART_CTXT_RELCTNT_NAME, name);
292         elm_object_focus_allow_set(ly, EINA_TRUE);
293
294         return ly;
295 }
296
297
298 Evas_Object *CContextView::_add_scroller(Evas_Object *eoBase)
299 {
300         Evas_Object *scroller;
301
302         if (!eoBase) {
303                 _ERR("Invalid argument.");
304                 return NULL;
305         }
306
307         scroller = elm_scroller_add(eoBase);
308         if (!scroller) {
309                 _ERR("elm_scroller_add failed.");
310                 return NULL;
311         }
312
313         evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
314                         EVAS_HINT_EXPAND);
315         evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL,
316                         EVAS_HINT_FILL);
317
318         return scroller;
319 }
320
321 Evas_Object *CContextView::_add_table(Evas_Object *eoBase)
322 {
323         Evas_Object *table;
324
325         if (!eoBase) {
326                 _ERR("Invalid argument.");
327                 return NULL;
328         }
329
330         table = elm_table_add(eoBase);
331         if (!table) {
332                 _ERR("elm_table_add failed.");
333                 return NULL;
334         }
335
336         elm_table_homogeneous_set(table, EINA_TRUE);
337         elm_table_padding_set(table,
338                         FBR_CTXT_TABLE_WPAD * elm_config_scale_get(),
339                         FBR_CTXT_TABLE_HPAD * elm_config_scale_get());
340         evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
341         evas_object_show(table);
342
343         return table;
344 }
345
346
347 Evas_Object *CContextView::_get_icon(Evas_Object *obj, CExtNameInfo *finfo)
348 {
349         Evas_Object *icon;
350         char *path;
351
352         path = finfo->Path();
353         if (!path)
354                 return NULL;
355
356         icon = elm_icon_add(obj);
357         if (!icon)
358                 return NULL;
359
360         elm_need_ethumb();
361         elm_icon_thumb_set(icon, path, NULL);
362         elm_image_aspect_fixed_set(icon, EINA_FALSE);
363
364         return icon;
365 }
366
367
368 void CContextView::_set_default_thumb(Evas_Object *img, int type)
369 {
370         char buf[MAX_LENGTH];
371
372         if (!img)
373                 return;
374
375         switch (type) {
376         case E_GRP_FOLDER:
377                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
378                                 FBR_IMAGE_FOLDER);
379                 break;
380
381         case E_GRP_VIDEO:
382                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
383                                 FBR_IMAGE_DEFAULT_VIDEO);
384                 break;
385
386         case E_GRP_MUSIC:
387                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
388                                 FBR_IMAGE_DEFAULT_MUSIC);
389                 break;
390
391         default:
392                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
393                                 FBR_IMAGE_DEFAULT_OTHER);
394                 break;
395         }
396
397         elm_image_file_set(img, buf, NULL);
398         elm_image_no_scale_set(img, EINA_TRUE);
399 }
400
401
402 Evas_Object *CContextView::_create_lbl(Evas_Object *ly, char *title)
403 {
404         Evas_Object *lbl;
405         const char *s;
406         char buf[MAX_LENGTH];
407
408         if (!title)
409                 return NULL;
410
411         lbl = elm_label_add(ly);
412         if (!lbl) {
413                 return NULL;
414         }
415
416         elm_object_style_set(lbl, FBR_STYLE_LABEL);
417         elm_label_ellipsis_set(lbl, EINA_TRUE);
418         s = edje_object_data_get(elm_layout_edje_get(ly),
419                         FBR_DATA_TITLE_WIDTH);
420         if (s)
421                 elm_label_wrap_width_set(lbl, atoi(s));
422         else
423                 _ERR("No title width exist");
424
425         snprintf(buf, sizeof(buf),
426                         "<align=left><color=#FFFFFFFF>"
427                         "<font=%s>"
428                         "<font_size=36>%s</font_size>"
429                         "</font></color></align>", FONT_STYLE_BOLD, _(title));
430         elm_object_text_set(lbl, buf);
431         elm_label_slide_speed_set(lbl, FBR_TITLE_SLIDE_SPEED);
432
433         return lbl;
434 }
435
436
437
438 void CContextView::m_SetBtnDownFocus(Evas_Object *btn)
439 {
440         ASSERT(m);
441
442         if (!m->link_first[0] && !m->rel_first[0]) {
443                 elm_object_focus_next_object_set(btn, btn,
444                         ELM_FOCUS_DOWN);
445                 return;
446         }
447
448         if (m->link_first[0])
449                 elm_object_focus_next_object_set(btn, m->link_first[0],
450                 ELM_FOCUS_DOWN);
451         else
452                 elm_object_focus_next_object_set(btn, m->rel_first[0],
453                 ELM_FOCUS_DOWN);
454 }
455
456
457 void CContextView::m_SetLayoutFocusOrder(Evas_Object *btn)
458 {
459         ASSERT(btn);
460
461         int i;
462         Evas_Object *obj;
463
464         if (m->link_first[0]) {
465                 elm_object_focus_next_object_set(m->link_first[0], btn,
466                         ELM_FOCUS_UP);
467                 elm_object_focus_next_object_set(m->link_first[0],
468                         m->rel_first[0], ELM_FOCUS_DOWN);
469                 elm_object_focus_next_object_set(m->link_first[1], btn,
470                         ELM_FOCUS_UP);
471                 elm_object_focus_next_object_set(m->link_first[1],
472                         m->rel_first[0], ELM_FOCUS_DOWN);
473         }
474
475         for (i = 0; i < TABLE_MAX_COL; i++) {
476                 if (!m->rel_first[i])
477                         continue;
478
479                 obj = m->rel_first[i];
480                 if (m->link_first[0])
481                         elm_object_focus_next_object_set(obj, m->link_first[0],
482                         ELM_FOCUS_UP);
483                 else
484                         elm_object_focus_next_object_set(obj, btn,
485                         ELM_FOCUS_UP);
486         }
487 }
488
489
490 Evas_Object *CContextView::m_AddButton(Evas_Object *eoBase)
491 {
492         ASSERT(eoBase);
493
494         Evas_Object *btn;
495
496         btn = elm_layout_add(eoBase);
497         if (!btn) {
498                 _ERR("elm_layout_add failed.");
499                 return NULL;
500         }
501
502         evas_object_size_hint_weight_set(btn,
503                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
504         evas_object_size_hint_align_set(btn, 0.0, 0.5);
505
506         elm_layout_file_set(btn, EDJEFILE, FBR_CONTEXT_BTN);
507         elm_object_focus_allow_set(btn, EINA_TRUE);
508         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
509         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
510         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
511
512         evas_object_smart_callback_add(btn, FBR_SIGNAL_FOCUSED,   _btn_focused, NULL);
513         evas_object_smart_callback_add(btn, FBR_SIGNAL_UNFOCUSED, _btn_unfocused, NULL);
514
515         evas_object_show(btn);
516         elm_object_focus_set(btn, EINA_TRUE);
517
518         return btn;
519 }
520
521
522 bool CContextView::m_AddTableContents(Evas_Object *table, Eina_List *list, enum content_app_type type)
523 {
524         ASSERT(list);
525
526         int row, col;
527         Evas_Object *ly;
528         Eina_List *l;
529         CDummyContent::SRelativeContent *rctnt;
530         void* obj;
531
532         row = 0;
533         col = 0;
534
535         EINA_LIST_FOREACH(list, l, obj) {
536                 rctnt = (CDummyContent::SRelativeContent *)obj;
537                 ly = _add_rltv_ctnt(table, rctnt->title, rctnt->imgpath);
538                 if (!ly)
539                         continue;
540                 //_SET_PRIV(ly, rctnt);
541                 elm_table_pack(table, ly, col, row, 1, 1);
542                 evas_object_show(ly);
543
544                 evas_object_smart_callback_add(ly, FBR_SIGNAL_FOCUSED,       _btn_focused, NULL);
545                 evas_object_smart_callback_add(ly, FBR_SIGNAL_UNFOCUSED,     _btn_unfocused, NULL);
546
547                 m->pHandlerButton->Connect(ly);
548
549                 if (row == 0) {
550                         if (type == APP_LINKED)
551                                 m->link_first[col] = ly;
552                         else
553                                 m->rel_first[col] = ly;
554                 }
555
556                 if (col == 0)
557                         elm_object_focus_next_object_set(ly, ly, ELM_FOCUS_LEFT);
558                 else if (col == TABLE_MAX_COL - 1)
559                         elm_object_focus_next_object_set(ly, ly, ELM_FOCUS_RIGHT);
560
561                 if (type == APP_LINKED)
562                         m->link_last[col] = ly;
563                 else
564                         m->rel_last[col] = ly;
565
566                 col++;
567                 if (col >= TABLE_MAX_COL) {
568                         row++;
569                         col = 0;
570                 }
571         }
572
573         return true;
574 }
575
576
577 bool CContextView::m_CreateContentApps(Eina_List *list, enum content_app_type type)
578 {
579         if (!list)
580                 return false;
581
582         Evas_Object *scroller, *table;
583         int r;
584
585         scroller = _add_scroller(m->eoBase);
586         if (!scroller) {
587                 _ERR("_add_scroller failed.");
588                 return false;
589         }
590
591         table = _add_table(scroller);
592         if (!table) {
593                 _ERR("_add_table failed.");
594                 evas_object_del(scroller);
595                 return false;
596         }
597
598         r = m_AddTableContents(table, list, type);
599         if (!r) {
600                 _ERR("m_AddTableContents failed.");
601                 evas_object_del(scroller);
602                 return false;
603         }
604
605         elm_object_content_set(scroller, table);
606
607         if (type == APP_LINKED)
608                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_LINK_AREA,
609                 scroller);
610         else
611                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_REL_AREA,
612                 scroller);
613
614         return true;
615 }
616
617
618 bool CContextView::m_CreateBtnsPart(void)
619 {
620         Evas_Object *btn, *box;
621         box = _add_btnbox(m->eoBase);
622         if (!box)
623                 return false;
624
625         btn = m_AddButton(box);
626         if (!btn) {
627                 evas_object_del(box);
628                 return false;
629         }
630         if (!_add_btn_info(btn, FBR_IMAGE_CTXT_OPEN, FBR_TEXT_OPEN)) {
631                 evas_object_del(box);
632                 return false;
633         }
634
635         m_SetBtnDownFocus(btn);
636         m_SetLayoutFocusOrder(btn);
637         elm_box_pack_end(box, btn);
638         m->eoBtnOpen = btn;
639
640         m->pHandlerButton->Connect(m->eoBtnOpen);
641
642         elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_BTNAREA, box);
643
644         return true;
645 }
646
647
648 bool CContextView::m_CreateInfoPart(void)
649 {
650         Evas_Object *img = NULL;
651         char *title = NULL;
652
653         char subtitle[MAX_LENGTH];
654         char subtitle2[MAX_LENGTH];
655
656         char *path = NULL;
657         Eina_List *rltvlist = NULL;
658         Eina_List *linkapplist = NULL;
659         int type;
660         Evas_Object *lbl = NULL;
661
662         if (!_get_context_details(m->finfo, &path, &title, subtitle, subtitle2))
663                 return false;
664
665         type = m->finfo->Type();
666         if (!path) {
667                 if (type == E_GRP_PHOTO) {
668                         img = _get_icon(m->eoBase, m->finfo);
669                         if (!img)
670                                 goto finish;
671                 } else {
672                         img = elm_image_add(m->eoBase);
673                         if (!img)
674                                 goto finish;
675                         _set_default_thumb(img, type);
676                 }
677         } else {
678                 img = elm_image_add(m->eoBase);
679                 if (!img)
680                         goto finish;
681                 elm_image_file_set(img, path, NULL);
682                 elm_image_aspect_fixed_set(img, EINA_FALSE);
683         }
684
685         elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_ICON, img);
686
687         lbl = _create_lbl(m->eoBase, title);
688         if (lbl) {
689                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_TITLE, lbl);
690                 _lbl_start_slide(lbl);
691         }
692
693         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_SUBTITLE,  subtitle);
694         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_SUBTITLE2, subtitle2);
695
696         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_LINK_TEXT, _(FBR_TEXT_LINK));
697         linkapplist = CDummyContent::ListLinkApp(type);
698         if (linkapplist)
699                 m_CreateContentApps(linkapplist, APP_LINKED);
700
701         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_REL_TEXT, _(FBR_TEXT_REL));
702         rltvlist = CDummyContent::ListRelative(type);
703         if (rltvlist)
704                 m_CreateContentApps(rltvlist, APP_OTHER);
705
706 finish:
707
708         return true;
709 }
710
711
712 void CContextView::sm_CbKeyPressed(void *dt, Evas *e, Evas_Object *obj, void *ei)
713 {
714         _DBG();
715         Evas_Event_Key_Down *ev;
716
717         if (!dt || !ei)
718                 return;
719
720         ev = (Evas_Event_Key_Down *)ei;
721
722         if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
723         {
724                 CViewMgr::GetInstance()->PopView();
725         }
726         else if (!strcmp(ev->keyname, KEY_EXIT))
727                 elm_exit();
728 }
729
730 void CContextView::t_OnShow(void)
731 {
732         evas_object_show(m->eoBase);
733 }
734
735 void CContextView::t_OnHide(void)
736 {
737         evas_object_hide(m->eoBase);
738 }
739
740 bool CContextView::Create(void *data)
741 {
742         ASSERT(!m);
743
744         Evas_Object *eoBase = NULL;
745         Evas_Object *eoWin = CViewMgr::GetInstance()->Window();
746
747
748         _CREATE_BEGIN{
749                 _CHECK(m = new SContextView)
750                 _CHECK(eoBase = elm_layout_add(eoWin))
751                 _CHECK(elm_layout_file_set(eoBase, EDJEFILE, FBR_CONTEXT_VIEW))
752                 _COMMAND{ m->eoWin = eoWin; m->eoBase = eoBase; m->finfo = (CExtNameInfo*)data; }
753                 _CHECK(m_CreateInfoPart())
754                 _CHECK(m_CreateBtnsPart())
755
756                 _WHEN_SUCCESS{
757                         evas_object_event_callback_add(eoBase, EVAS_CALLBACK_KEY_DOWN, sm_CbKeyPressed, m);
758                 }
759
760                 _CHECK_FAIL{ /* m_CreateBtnsPart */ }
761                 _CHECK_FAIL{ /* m_CreateInfoPart */ }
762                 _CHECK_FAIL{}
763                 _CHECK_FAIL{ evas_object_del(eoBase);  }
764                 _CHECK_FAIL{ delete m; m = NULL; }
765         } _CREATE_END_AND_CATCH{ return false; }
766
767         return true;
768 }
769
770 void CContextView::Destroy(void)
771 {
772         ASSERT(m);
773
774         evas_object_del(m->eoBase);
775         delete m;
776         m = NULL;
777 }
778
779 Evas_Object* CContextView::Base(void)
780 {
781         ASSERT(m);
782
783         return m->eoBase;
784 }