Code sync
[apps/native/starter.git] / lock-setting / lockscreen-options / src / lockscreen-options-shortcuts.c
1  /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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
18
19 #include <Elementary.h>
20 #include <Ecore_X.h>
21 #include <ail.h>
22 #include <vconf.h>
23 #include <vconf-keys.h>
24
25 #include "lockscreen-options.h"
26 #include "lockscreen-options-debug.h"
27 #include "lockscreen-options-util.h"
28 #include "lockscreen-options-shortcuts.h"
29 #include "lockscreen-options-shortcuts-edit.h"
30
31
32 #define EDJE_DIR                    "/usr/ug/res/edje/ug-lockscreen-options-efl"
33 #define IMAGES_DIR                  "/usr/ug/res/images/ug-lockscreen-options-efl"
34 #define GENGRID_ITEM_HEIGHT         188
35 #define WINDOW_HEIGHT               1280
36
37 typedef enum {
38         SET_SHORTCUTS_APP1 = 0,
39         SET_SHORTCUTS_APP2,
40         SET_SHORTCUTS_APP3,
41         SET_SHORTCUTS_APP4
42 } shortcuts_type_t;
43
44 typedef struct {
45         int index;
46         char *app_icon;
47         char *app_name;
48         char *pkg_name;
49 } app_list_item_s;
50
51 typedef struct {
52         int index;
53         char *pkg_name;
54         Elm_Object_Item *item;
55 } shortcuts_item_s;
56
57 typedef struct {
58         lockscreen_options_ug_data *ug_data;
59         Evas_Object *gengrid;
60         Eina_List *app_list;
61         shortcuts_type_t shortcuts_type;
62         Elm_Object_Item *selected_gengrid_item;
63         Eina_Bool is_moved;
64 } options_shortcuts_view_s;
65
66 static Elm_Gengrid_Item_Class gic;
67 static Elm_Genlist_Item_Class ltc;
68 static options_shortcuts_view_s *options_shortcuts_view_data = NULL;
69 static Evas_Object *edit_item = NULL;
70
71 static Eina_Bool _lockscreen_options_package_name_compare(const char *pkg_name)
72 {
73         char *temp_name = NULL;
74
75         temp_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT1);
76         if ((temp_name != NULL) && (strcmp(pkg_name, temp_name) == 0)) {
77                 LOCKOPTIONS_DBG("pkg_name is %s", pkg_name);
78                 free(temp_name);
79                 temp_name = NULL;
80                 return EINA_TRUE;
81         }
82
83         temp_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT2);
84         if ((temp_name != NULL) && (strcmp(pkg_name, temp_name) == 0)) {
85                 LOCKOPTIONS_DBG("pkg_name is %s", pkg_name);
86                 free(temp_name);
87                 temp_name = NULL;
88                 return EINA_TRUE;
89         }
90
91         temp_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT3);
92         if ((temp_name != NULL) && (strcmp(pkg_name, temp_name) == 0)) {
93                 LOCKOPTIONS_DBG("pkg_name is %s", pkg_name);
94                 free(temp_name);
95                 temp_name = NULL;
96                 return EINA_TRUE;
97         }
98
99         temp_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT4);
100         if ((temp_name != NULL) && (strcmp(pkg_name, temp_name) == 0)) {
101                 LOCKOPTIONS_DBG("pkg_name is %s", pkg_name);
102                 free(temp_name);
103                 temp_name = NULL;
104                 return EINA_TRUE;
105         }
106
107         return EINA_FALSE;
108 }
109
110 static char *_lockscreen_options_icon_path_get(shortcuts_item_s *
111                                                shortcuts_item)
112 {
113         ail_appinfo_h handle;
114         ail_error_e ret;
115         char *pkg_name = NULL;
116         char *temp = NULL;
117         char *icon_path = NULL;
118         shortcuts_type_t shortcuts_type = SET_SHORTCUTS_APP1;
119
120         if (shortcuts_item == NULL) {
121                 return NULL;
122         }
123
124         shortcuts_type = shortcuts_item->index;
125
126         switch (shortcuts_type) {
127         case SET_SHORTCUTS_APP1:
128                 pkg_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT1);
129                 LOCKOPTIONS_ERR("pkg_name is %s", pkg_name);
130                 break;
131         case SET_SHORTCUTS_APP2:
132                 pkg_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT2);
133                 LOCKOPTIONS_ERR("pkg_name is %s", pkg_name);
134                 break;
135         case SET_SHORTCUTS_APP3:
136                 pkg_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT3);
137                 LOCKOPTIONS_ERR("pkg_name is %s", pkg_name);
138                 break;
139         case SET_SHORTCUTS_APP4:
140                 pkg_name = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT4);
141                 LOCKOPTIONS_ERR("pkg_name is %s", pkg_name);
142                 break;
143         default:
144                 break;
145         }
146
147         if (pkg_name == NULL || strlen(pkg_name) == 0) {
148                 LOCKOPTIONS_ERR("pkg_name is NULL");
149                 return NULL;
150         }
151         shortcuts_item->pkg_name = strdup(pkg_name);
152
153         ret = ail_get_appinfo(pkg_name, &handle);
154         if (ret != AIL_ERROR_OK) {
155                 LOCKOPTIONS_ERR("Fail to ail_get_appinfo");
156                 return NULL;
157         }
158
159         ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &temp);
160         if (ret != AIL_ERROR_OK) {
161                 LOCKOPTIONS_ERR("Fail to ail_appinfo_get_str");
162                 ail_destroy_appinfo(handle);
163                 return NULL;
164         }
165
166         if (temp) {
167                 icon_path = strdup(temp);
168         }
169
170         ret = ail_destroy_appinfo(handle);
171         if (ret != AIL_ERROR_OK) {
172                 LOCKOPTIONS_ERR("Fail to ail_destroy_appinfo");
173         }
174
175         if (pkg_name) {
176                 free(pkg_name);
177                 pkg_name = NULL;
178         }
179         return icon_path;
180 }
181
182 static void _lockscreen_options_shortcuts_set(shortcuts_type_t shortcuts_type,
183                                               const char *pkg_name)
184 {
185         int ret = 0;
186
187         switch (shortcuts_type) {
188         case SET_SHORTCUTS_APP1:
189                 ret = vconf_set_str(VCONFKEY_LOCKSCREEN_SHORTCUT1, pkg_name);
190                 if (ret != 0) {
191                         LOCKOPTIONS_ERR("set failed");
192                 }
193                 break;
194         case SET_SHORTCUTS_APP2:
195                 ret = vconf_set_str(VCONFKEY_LOCKSCREEN_SHORTCUT2, pkg_name);
196                 if (ret != 0) {
197                         LOCKOPTIONS_ERR("set failed");
198                 }
199                 break;
200         case SET_SHORTCUTS_APP3:
201                 ret = vconf_set_str(VCONFKEY_LOCKSCREEN_SHORTCUT3, pkg_name);
202                 if (ret != 0) {
203                         LOCKOPTIONS_ERR("set failed");
204                 }
205                 break;
206         case SET_SHORTCUTS_APP4:
207                 ret = vconf_set_str(VCONFKEY_LOCKSCREEN_SHORTCUT4, pkg_name);
208                 if (ret != 0) {
209                         LOCKOPTIONS_ERR("set failed");
210                 }
211                 break;
212         default:
213                 break;
214         }
215 }
216
217 ail_cb_ret_e _lockscreen_options_appinfo_func(const ail_appinfo_h appinfo,
218                                               void *user_data)
219 {
220         char *pkg_name = NULL;
221         char *app_name = NULL;
222         char *app_icon = NULL;
223         int index = 0;
224         Eina_Bool is_same = EINA_FALSE;
225
226         if (AIL_ERROR_OK !=
227             ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &pkg_name)) {
228                 LOCKOPTIONS_ERR("cannot get package name");
229         }
230
231         is_same = _lockscreen_options_package_name_compare(pkg_name);
232
233         LOCKOPTIONS_DBG("is_same = %d", is_same);
234         if (is_same == EINA_FALSE) {
235                 app_list_item_s *list_item =
236                     (app_list_item_s *) calloc(1, sizeof(app_list_item_s));
237
238                 if (pkg_name) {
239                         list_item->pkg_name = strdup(pkg_name);
240                 }
241
242                 if (AIL_ERROR_OK !=
243                     ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR,
244                                         &app_name)) {
245                         LOCKOPTIONS_ERR("cannot get App name");
246                 }
247                 if (AIL_ERROR_OK !=
248                     ail_appinfo_get_str(appinfo, AIL_PROP_ICON_STR,
249                                         &app_icon)) {
250                         LOCKOPTIONS_ERR("cannot get App icon");
251                 }
252                 list_item->index = index;
253                 if (app_name) {
254                         list_item->app_name = strdup(app_name);
255                 }
256                 if (app_icon && (strcmp(app_icon, "(null)") != 0)) {
257                         list_item->app_icon = strdup(app_icon);
258                 } else {
259                         list_item->app_icon =
260                             strdup(IMAGES_DIR "/mainmenu_icon.png");
261                 }
262                 options_shortcuts_view_data->app_list =
263                     eina_list_append(options_shortcuts_view_data->app_list,
264                                      list_item);
265                 index++;
266         }
267
268         return AIL_CB_RET_CONTINUE;
269 }
270
271 void _lockscreen_options_list_all_packages()
272 {
273         ail_filter_h filter;
274         ail_error_e ret;
275
276         ret = ail_filter_new(&filter);
277         if (ret != AIL_ERROR_OK) {
278                 return;
279         }
280
281         ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_TASKMANAGE_BOOL, true);
282         if (ret != AIL_ERROR_OK) {
283                 return;
284         }
285
286         ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
287         if (ret != AIL_ERROR_OK) {
288                 return;
289         }
290
291         ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
292         if (ret != AIL_ERROR_OK) {
293                 return;
294         }
295
296         ail_filter_list_appinfo_foreach(filter,
297                                         _lockscreen_options_appinfo_func, NULL);
298         ail_filter_destroy(filter);
299 }
300
301 static void _lockscreen_options_select_apps_delete_cb(void *data, Evas * e,
302                                                       Evas_Object * obj,
303                                                       void *event_info)
304 {
305         void *list_item_data = NULL;
306
307         EINA_LIST_FREE(options_shortcuts_view_data->app_list, list_item_data) {
308                 if (list_item_data) {
309                         free(list_item_data);
310                         list_item_data = NULL;
311                 }
312         }
313 }
314
315 static void _lockscreen_options_shortcuts_delete_cb(void *data, Evas * e,
316                                                     Evas_Object * obj,
317                                                     void *event_info)
318 {
319         void *list_item_data = NULL;
320
321         if (options_shortcuts_view_data == NULL) {
322                 return;
323         }
324
325         EINA_LIST_FREE(options_shortcuts_view_data->app_list, list_item_data) {
326                 if (list_item_data) {
327                         free(list_item_data);
328                         list_item_data = NULL;
329                 }
330         }
331         if (options_shortcuts_view_data->gengrid) {
332                 evas_object_del(options_shortcuts_view_data->gengrid);
333                 options_shortcuts_view_data->gengrid = NULL;
334         }
335         if (options_shortcuts_view_data) {
336                 free(options_shortcuts_view_data);
337                 options_shortcuts_view_data = NULL;
338         }
339 }
340
341 static void _lockscreen_options_shortcuts_back_cb(void *data, Evas_Object * obj,
342                                                   void *event_info)
343 {
344         lockscreen_options_ug_data *ug_data =
345             (lockscreen_options_ug_data *) data;
346         if (ug_data == NULL) {
347                 return;
348         }
349         Evas_Object *navi_bar = ug_data->navi_bar;
350
351         if (navi_bar == NULL) {
352                 LOCKOPTIONS_ERR("navi_bar is null.");
353                 return;
354         }
355
356         elm_naviframe_item_pop(navi_bar);
357 }
358
359 //not used now
360 static void _lockscreen_options_shortcuts_thumbnail_delete_cb(void *data,
361                                                               Evas_Object * obj,
362                                                               void *event_info)
363 {
364         LOCKOPTIONS_DBG("_lockscreen_options_shortcuts_thumbnail_delete_cb");
365         Elm_Object_Item *object_item = NULL;
366         shortcuts_item_s *shortcuts_item = (shortcuts_item_s *) data;
367
368         if (shortcuts_item == NULL) {
369                 return;
370         }
371
372         _lockscreen_options_shortcuts_set(shortcuts_item->index, "");
373
374         object_item =
375             elm_gengrid_first_item_get(options_shortcuts_view_data->gengrid);
376         while (object_item) {
377                 shortcuts_item_s *shortcuts_item_info = NULL;
378                 shortcuts_item_info = elm_object_item_data_get(object_item);
379                 if (shortcuts_item->index == shortcuts_item_info->index) {
380                         elm_gengrid_item_update(object_item);
381                 }
382                 object_item = elm_gengrid_item_next_get(object_item);
383         }
384 }
385
386 //not used now
387 static void _lockscreen_options_grid_moved_cb(void *data, Evas_Object * obj,
388                                               void *event_info)
389 {
390         int index = 0;
391         Elm_Object_Item *object_item = NULL;
392         shortcuts_item_s *shortcuts_item = NULL;
393
394         options_shortcuts_view_data->is_moved = EINA_TRUE;
395
396         object_item =
397             elm_gengrid_first_item_get(options_shortcuts_view_data->gengrid);
398         while (object_item) {
399                 shortcuts_item = elm_object_item_data_get(object_item);
400                 if (shortcuts_item) {
401                         LOCKOPTIONS_DBG
402                             ("index = %d, shortcuts_item->pkg_name = %s.",
403                              index, shortcuts_item->pkg_name);
404                         shortcuts_item->index = index;
405                         if ((shortcuts_item->pkg_name == NULL)
406                             || (strlen(shortcuts_item->pkg_name) == 0)
407                             || (strcmp(shortcuts_item->pkg_name, "(null)") ==
408                                 0)) {
409                                 _lockscreen_options_shortcuts_set(index, "");
410                         } else {
411                                 _lockscreen_options_shortcuts_set(index,
412                                                                   shortcuts_item->pkg_name);
413                         }
414                 }
415                 object_item = elm_gengrid_item_next_get(object_item);
416                 index++;
417         }
418 }
419
420 static void _lockscreen_options_gengrid_select_cb(void *data, Evas_Object * obj,
421                                                   const char *emission,
422                                                   const char *source)
423 {
424         shortcuts_item_s *shortcuts_item = (shortcuts_item_s *) data;
425
426         if (shortcuts_item == NULL
427             || options_shortcuts_view_data->is_moved == EINA_TRUE) {
428                 options_shortcuts_view_data->is_moved = EINA_FALSE;
429                 return;
430         }
431         LOCKOPTIONS_DBG("_lockscreen_options_gengrid_select_cb.");
432         if (shortcuts_item->item != NULL) {
433                 options_shortcuts_view_data->selected_gengrid_item =
434                     shortcuts_item->item;
435                 elm_gengrid_item_selected_set(shortcuts_item->item, EINA_FALSE);
436                 _lockscreen_options_select_applications_create
437                     (shortcuts_item->index);
438         }
439 }
440
441 static Evas_Object *_lockscreen_options_grid_content_get(void *data,
442                                                          Evas_Object * obj,
443                                                          const char *part)
444 {
445         char *icon_path = NULL;
446         Evas_Object *icon = NULL;
447         Evas_Object *layout = NULL;
448         shortcuts_item_s *shortcuts_item = (shortcuts_item_s *) data;
449         LOCKOPTIONS_DBG("_lockscreen_options_grid_content_get.");
450
451         if (shortcuts_item == NULL) {
452                 return NULL;
453         }
454
455         if (!strcmp(part, "elm.swallow.icon")) {
456                 layout =
457                     lockscreen_options_util_create_layout(obj,
458                                                           EDJE_DIR
459                                                           "/lockscreen-options.edj",
460                                                           "lockscreen.options.shortcuts.thumbnail.main");
461                 icon_path = _lockscreen_options_icon_path_get(shortcuts_item);
462                 icon = elm_icon_add(layout);
463                 if (icon_path) {
464                         elm_icon_file_set(icon, icon_path, NULL);
465                         elm_object_part_content_set(layout,
466                                                     "elm.swallow.contents",
467                                                     icon);
468                         elm_icon_aspect_fixed_set(icon, EINA_FALSE);
469                         /*button = elm_button_add(layout);
470                         elm_object_style_set(button, "minus/extended");
471                         evas_object_pass_events_set(button, 1);
472                         evas_object_repeat_events_set(button, 0);
473                         evas_object_propagate_events_set(button, 0);
474                         elm_object_part_content_set(layout,
475                                                     "elm.swallow.button",
476                                                     button);
477                         evas_object_smart_callback_add(button, "clicked",
478                                                        _lockscreen_options_shortcuts_thumbnail_delete_cb,
479                                                        shortcuts_item);*/
480                         free(icon_path);
481                         icon_path = NULL;
482                 } else {
483                         elm_icon_file_set(icon, IMAGES_DIR "/icon_add.png",
484                                           NULL);
485                         elm_object_part_content_set(layout,
486                                                     "elm.swallow.contents",
487                                                     icon);
488                 }
489                 edje_object_signal_callback_add(elm_layout_edje_get(layout),
490                                                 "mouse,clicked,*", "background",
491                                                 _lockscreen_options_gengrid_select_cb,
492                                                 shortcuts_item);
493                 return layout;
494         }
495         return NULL;
496 }
497
498 static void _lockscreen_options_grid_del(void *data, Evas_Object * obj)
499 {
500         shortcuts_item_s *shortcuts_item = (shortcuts_item_s *) data;
501
502         if (shortcuts_item == NULL) {
503                 return;
504         }
505         if (shortcuts_item->pkg_name) {
506                 free(shortcuts_item->pkg_name);
507                 shortcuts_item->pkg_name = NULL;
508         }
509         free(shortcuts_item);
510         shortcuts_item = NULL;
511 }
512
513 static void _lockscreen_options_shortcuts_help_text_create(Evas_Object * parent)
514 {
515         Evas_Object *title_label = NULL;
516         Evas_Object *contents_label = NULL;
517         char buffer[1024] = { 0 };
518
519         title_label = elm_label_add(parent);
520         snprintf(buffer, sizeof(buffer),
521                  "<font_size=40><align=center>%s</align></font_size>",
522                  lockscreen_optoins_get_string
523                  (IDS_LOCKSCREEN_OPTIONS_SET_SHORTCUTS_ON_LOCKSCREEN));
524         elm_object_text_set(title_label, buffer);
525         evas_object_show(title_label);
526         elm_object_part_content_set(parent, "shortcuts.help.title",
527                                     title_label);
528
529         contents_label = elm_label_add(parent);
530         snprintf(buffer, sizeof(buffer),
531                  "<font_size=32><align=center><color=#7C7C7C>%s</color></align></font_size>",
532                  lockscreen_optoins_get_string
533                  (IDS_LOCKSCREEN_OPTIONS_TAP_SHORTCUTS));
534         elm_object_text_set(contents_label, buffer);
535         evas_object_show(contents_label);
536         elm_object_part_content_set(parent, "shortcuts.help.contents",
537                                     contents_label);
538 }
539
540 static void _lockscreen_options_shortcuts_gengrid_create(Evas_Object * parent)
541 {
542         Evas_Coord window_width = 0;
543         Evas_Coord window_height = 0;
544         Evas_Object *gengrid = NULL;
545         int index = 0;
546
547         gengrid = elm_gengrid_add(parent);
548         ecore_x_window_size_get(ecore_x_window_root_first_get(), &window_width,
549                                 &window_height);
550         elm_gengrid_item_size_set(gengrid, window_width / 4,
551                                   GENGRID_ITEM_HEIGHT * window_height /
552                                   WINDOW_HEIGHT);
553         elm_gengrid_align_set(gengrid, 0.5, 0.0);
554         //elm_gengrid_reorder_mode_set(gengrid, EINA_TRUE),
555             evas_object_show(gengrid);
556         elm_object_part_content_set(parent, "shortcuts.gengrid", gengrid);
557
558         /*evas_object_smart_callback_add(gengrid, "moved",
559                                        _lockscreen_options_grid_moved_cb, NULL);*/
560         options_shortcuts_view_data->gengrid = gengrid;
561
562         gic.item_style = "default_grid";
563         gic.func.text_get = NULL;
564         gic.func.content_get = _lockscreen_options_grid_content_get;
565         gic.func.state_get = NULL;
566         gic.func.del = _lockscreen_options_grid_del;
567
568         for (index = 0; index <= SET_SHORTCUTS_APP4; index++) {
569                 shortcuts_item_s *shortcuts_item =
570                     (shortcuts_item_s *) calloc(1, sizeof(shortcuts_item_s));
571                 shortcuts_item->index = index;
572                 shortcuts_item->item =
573                     elm_gengrid_item_append(gengrid, &gic,
574                                             (void *)shortcuts_item, NULL,
575                                             (void *)shortcuts_item);
576         }
577 }
578
579 static char *_lockscreen_options_gl_text_get(void *data, Evas_Object * obj,
580                                              const char *part)
581 {
582         int index = (int)data;
583         app_list_item_s *list_item = (app_list_item_s *)
584             eina_list_nth(options_shortcuts_view_data->app_list, index);
585
586         if (list_item == NULL || list_item->app_name == NULL) {
587                 return NULL;
588         }
589
590         if (!strcmp(part, "elm.text")) {
591                 return strdup(list_item->app_name);
592         }
593         return NULL;
594 }
595
596 static Evas_Object *_lockscreen_options_gl_content_get(void *data,
597                                                        Evas_Object * obj,
598                                                        const char *part)
599 {
600         int index = (int)data;
601         Evas_Object *icon = NULL;
602         app_list_item_s *list_item = (app_list_item_s *)
603             eina_list_nth(options_shortcuts_view_data->app_list, index);
604
605         if (list_item == NULL || list_item->app_icon == NULL) {
606                 return NULL;
607         }
608
609         if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon")) {
610                 icon = elm_icon_add(obj);
611                 elm_icon_file_set(icon, list_item->app_icon, NULL);
612                 return icon;
613         }
614
615         return NULL;
616 }
617
618 static void _lockscreen_options_gl_options_sel(void *data, Evas_Object * obj,
619                                                void *event_info)
620 {
621         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
622         int index = (int)data;
623         app_list_item_s *list_item = (app_list_item_s *)
624             eina_list_nth(options_shortcuts_view_data->app_list, index);
625
626         if (list_item == NULL || list_item->pkg_name == NULL) {
627                 return;
628         }
629         LOCKOPTIONS_DBG("list_item->pkg_name = %s", list_item->pkg_name);
630         if (item != NULL) {
631                 elm_genlist_item_selected_set(item, EINA_FALSE);
632                 _lockscreen_options_shortcuts_set
633                     (options_shortcuts_view_data->shortcuts_type,
634                      list_item->pkg_name);
635                 elm_gengrid_item_update
636                     (options_shortcuts_view_data->selected_gengrid_item);
637         }
638         elm_naviframe_item_pop(options_shortcuts_view_data->ug_data->navi_bar);
639         Eina_Bool is_have = EINA_FALSE;
640         is_have = lockscreen_options_shortcuts_check_items();
641         if(is_have == EINA_TRUE){
642                 elm_object_disabled_set(edit_item, EINA_FALSE);
643         }else{
644                 elm_object_disabled_set(edit_item, EINA_TRUE);
645         }
646 }
647
648 void _lockscreen_options_select_applications_create(shortcuts_type_t
649                                                     shortcuts_type)
650 {
651         Evas_Object *genlist = NULL;
652         int index = 0;
653
654         _lockscreen_options_list_all_packages();
655
656         options_shortcuts_view_data->shortcuts_type = shortcuts_type;
657         genlist =
658             elm_genlist_add(options_shortcuts_view_data->ug_data->navi_bar);
659
660         ltc.item_style = "1text.1icon.2";
661         ltc.func.text_get = _lockscreen_options_gl_text_get;
662         ltc.func.content_get = _lockscreen_options_gl_content_get;
663         ltc.func.state_get = NULL;
664         ltc.func.del = NULL;
665
666         for (index = 0;
667              index < eina_list_count(options_shortcuts_view_data->app_list);
668              index++) {
669                 elm_genlist_item_append(genlist, &ltc, (void *)index, NULL,
670                                         ELM_GENLIST_ITEM_NONE,
671                                         _lockscreen_options_gl_options_sel,
672                                         (void *)index);
673         }
674
675         evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL,
676                                        _lockscreen_options_select_apps_delete_cb,
677                                        NULL);
678         elm_naviframe_item_push(options_shortcuts_view_data->ug_data->navi_bar, lockscreen_optoins_get_string(IDS_LOCKSCREEN_OPTIONS_SELECT_APPLICATIONS), NULL, NULL, genlist, NULL);  /* the same tile */
679 }
680
681 static void _lockscreen_options_shortcuts_edit_cb(void *data, Evas_Object * obj, void *event_info)
682 {
683         lockscreen_options_shortcuts_create_edit_view(data);
684 }
685
686 void lockscreen_options_shortcuts_create_view(void *data)
687 {
688         lockscreen_options_ug_data *ug_data =
689             (lockscreen_options_ug_data *) data;
690         if (ug_data == NULL) {
691                 return;
692         }
693         Evas_Object *navi_bar = ug_data->navi_bar;
694         Evas_Object *layout = NULL;
695
696         if (navi_bar == NULL) {
697                 LOCKOPTIONS_ERR("navi_bar is null.");
698                 return;
699         }
700
701         options_shortcuts_view_data =
702             (options_shortcuts_view_s *) calloc(1,
703                                                 sizeof
704                                                 (options_shortcuts_view_s));
705         options_shortcuts_view_data->ug_data = ug_data;
706
707         layout =
708             lockscreen_options_util_create_layout(navi_bar,
709                                                   EDJE_DIR
710                                                   "/lockscreen-options.edj",
711                                                   "lockscreen.options.shortcuts.main");
712         _lockscreen_options_shortcuts_help_text_create(layout);
713         _lockscreen_options_shortcuts_gengrid_create(layout);
714
715         edit_item= elm_button_add(navi_bar);
716         elm_object_style_set(edit_item, "naviframe/toolbar/default");
717         elm_object_text_set(edit_item, _S("IDS_COM_BODY_EDIT"));
718         evas_object_smart_callback_add(edit_item, "clicked", _lockscreen_options_shortcuts_edit_cb, ug_data);
719
720         Evas_Object *back_button = elm_button_add(navi_bar);
721         elm_object_style_set(back_button, "naviframe/back_btn/default");
722         evas_object_smart_callback_add(back_button, "clicked", _lockscreen_options_shortcuts_back_cb, ug_data);
723         evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL,
724                                         _lockscreen_options_shortcuts_delete_cb, NULL);
725
726
727         Elm_Object_Item *navi_item = elm_naviframe_item_push(navi_bar, lockscreen_optoins_get_string(IDS_LOCKSCREEN_OPTIONS_SET_SHORTCUTS), back_button, NULL, layout, NULL);   /* the same tile */
728         elm_object_item_part_content_set(navi_item , "toolbar_button1", edit_item);
729
730         Eina_Bool is_have = EINA_FALSE;
731         is_have = lockscreen_options_shortcuts_check_items();
732         if(is_have == EINA_TRUE){
733                 elm_object_disabled_set(edit_item, EINA_FALSE);
734         }else{
735                 elm_object_disabled_set(edit_item, EINA_TRUE);
736         }
737 }
738
739 void lockscreen_options_shortcuts_update_view()
740 {
741         Elm_Object_Item *object_item = NULL;
742
743         object_item = elm_gengrid_first_item_get(options_shortcuts_view_data->gengrid);
744         while (object_item) {
745                 elm_gengrid_item_update(object_item);
746                 object_item = elm_gengrid_item_next_get(object_item);
747         }
748
749         Eina_Bool is_have = EINA_FALSE;
750         is_have = lockscreen_options_shortcuts_check_items();
751         if(is_have == EINA_TRUE){
752                 elm_object_disabled_set(edit_item, EINA_FALSE);
753         }else{
754                 elm_object_disabled_set(edit_item, EINA_TRUE);
755         }
756 }
757
758 Eina_Bool lockscreen_options_shortcuts_check_items()
759 {
760         char *pkg_name1 = NULL;
761         char *pkg_name2 = NULL;
762         char *pkg_name3 = NULL;
763         char *pkg_name4 = NULL;
764         Eina_Bool is_have = EINA_FALSE;
765
766         pkg_name1 = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT1);
767         pkg_name2 = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT2);
768         pkg_name3 = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT3);
769         pkg_name4 = vconf_get_str(VCONFKEY_LOCKSCREEN_SHORTCUT4);
770
771         if((pkg_name1 == NULL || strlen(pkg_name1) == 0) && (pkg_name2 == NULL || strlen(pkg_name2) == 0)
772                 && (pkg_name3 == NULL || strlen(pkg_name3) == 0) && (pkg_name4 == NULL || strlen(pkg_name4) == 0))
773         {
774                 is_have = EINA_FALSE;
775                 //elm_object_disabled_set(edit_item, EINA_TRUE);
776         }
777         else
778         {
779                 is_have = EINA_TRUE;
780                 //elm_object_disabled_set(edit_item, EINA_FALSE);
781         }
782         if(pkg_name1 != NULL)
783         {
784                 free(pkg_name1);
785                 pkg_name1 = NULL;
786         }
787         if(pkg_name2 != NULL)
788         {
789                 free(pkg_name2);
790                 pkg_name2 = NULL;
791         }
792         if(pkg_name3 != NULL)
793         {
794                 free(pkg_name3);
795                 pkg_name3 = NULL;
796         }
797         if(pkg_name4 != NULL)
798         {
799                 free(pkg_name4);
800                 pkg_name4 = NULL;
801         }
802         return is_have;
803 }