update tizen source
[pkgs/l/libug-setting-theme-efl.git] / setting-theme-efl.c
1 /*
2
3    Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
4
5    This file is part of libug-setting-theme-efl
6    Written by Shinwoo Kim <cinoo.kim@samsung.com>,
7               ChunEon Park <chuneon.park@samsung.com>,
8               Woohyun Jung <wh0705.jung@samsung.com>,
9               Jaehwan Kim <jae.hwan.kim@samsung.com>,
10               Juyung Seo <juyung.seo@samsung.com>,
11
12    PROPRIETARY/CONFIDENTIAL
13
14    This software is the confidential and proprietary information of
15    SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
16    disclose such Confidential Information and shall use it only in
17    accordance with the terms of the license agreement you entered
18    into with SAMSUNG ELECTRONICS.
19
20    SAMSUNG make no representations or warranties about the suitability
21    of the software, either express or implied, including but not limited
22    to the implied warranties of merchantability, fitness for a particular
23    purpose, or non-infringement. SAMSUNG shall not be liable for any
24    damages suffered by licensee as a result of using, modifying or
25    distributing this software or its derivatives.
26
27 */
28
29 #ifndef UG_MODULE_API
30 #define UG_MODULE_API __attribute__ ((visibility("default")))
31 #endif
32
33 #include <Eina.h>
34 #include <ui-gadget-module.h>
35 #include <aul.h>
36 #include <vconf.h>
37 #include <vconf-keys.h>
38 #include <Efreet_Mime.h>
39
40 #include "setting-theme-efl.h"
41
42 static Evas_Object *_parent = NULL;
43 static Elm_Genlist_Item_Class itc, itc2, edit_mode_itc;
44 static Eina_List *gtheme_list = NULL;
45 static Evas_Object *rdg = NULL;
46
47 struct ug_down_theme_property
48 {
49    int ext;
50    char name[SETTING_THEME_NAME_MAX_LEN];
51 };
52
53 struct ug_theme_list
54 {
55    struct ug_down_theme_property icon_theme;
56    struct ug_down_theme_property boot_ani_theme;
57    struct ug_down_theme_property key_snd_theme;
58    struct ug_down_theme_property efl_theme;
59    struct ug_down_theme_property gtk_theme;
60    struct ug_down_theme_property screen_image_theme;
61    struct ug_down_theme_property font_theme;
62    struct ug_down_theme_property vibrate_theme;
63 };
64
65 typedef enum
66 {
67    THEME_TYPE_DEFAULT,
68    THEME_TYPE_DOWNLOAD,
69 } ug_theme_type;
70
71 struct ug_theme_info
72 {
73    ug_theme_type type;
74    char* name;
75 };
76
77 typedef struct _Item_Data Item_Data;
78 typedef struct _View_Data View_Data;
79 struct _View_Data {
80    Evas_Object *bg;
81    Evas_Object *nf;
82    Evas_Object *box;
83    Evas_Object *delete_btn;             // 'Delete'/'Cancel' button
84    Evas_Object *more_btn;
85    Evas_Object *cbar;
86    Elm_Object_Item *del_btn_item; // 'Delete' button
87
88    Evas_Object *genlist;
89    Elm_Object_Item *renamed_it;
90
91    Evas_Object *select_all_layout;
92    Evas_Object *select_all_checkbox;
93    Eina_Bool select_all_checked;
94    int total_count;
95    int checked_count;
96    int default_theme_count;
97 };
98
99 struct _Item_Data {
100    Elm_Object_Item *it;  // Genlist Item pointer
101    Eina_Bool checked;     // Check status
102    char *label;
103    int idx;
104 };
105
106 struct ug_data {
107    Evas_Object *base;
108    Eina_List *theme_list;
109    struct ui_gadget *ug;
110    struct ug_theme_list theme;
111    View_Data *vd;
112 };
113
114 static Evas_Object* _create_layout_main( Evas_Object* parent, View_Data* vd )
115 {
116    Evas_Object *layout = elm_layout_add( parent );
117    if( layout == NULL ) return NULL;
118
119    elm_layout_theme_set( layout, "layout", "application", "default" );
120    evas_object_size_hint_weight_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121
122    //Background
123    Evas_Object *bg = elm_bg_add( layout );
124    vd->bg = bg;
125
126    if ( bg ) {
127       elm_object_style_set( bg, "group_list");
128       evas_object_size_hint_weight_set( bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND );
129       elm_object_part_content_set( layout, "elm.swallow.bg", bg );
130    }
131
132    evas_object_show( layout );
133
134    return layout;
135 }
136
137 static void _setting_theme_def_response_cb( void *data, Evas_Object *obj, void *event_info )
138 {
139    evas_object_del(obj);
140 }
141
142 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
143 {
144     // Popup remove code...ex
145     /*if (conformant) {
146       evas_object_del(conformant);
147       conformant = NULL;
148       }
149       if (del_timer) {
150       ecore_timer_del(del_timer);
151       del_timer = NULL;
152       }
153       evas_object_del(obj);*/
154 }
155
156 static int _load_index_file(struct ug_data* ugd, struct ug_theme_info* selected_theme)
157 {
158    FILE* fp = NULL;
159    Eina_Strbuf* temp_str_buf = eina_strbuf_new();
160    Eina_List *index_list = NULL;
161    Eina_List *elist = NULL;
162    char* meta_theme = NULL;
163
164    eina_strbuf_append_printf( temp_str_buf, "%s/%s/%s", DOWNLOAD_THEME_FOLDER_PATH, selected_theme->name, DOWNLOAD_THEME_INDEX_FILE_NAME);
165
166    if( !( fp = fopen( eina_strbuf_string_steal( temp_str_buf ), "r" ) ) ) {
167
168       //make error popup : file not found
169       Evas_Object *popup = elm_popup_add( ugd->base );
170
171       if( popup == NULL ) {
172          eina_strbuf_free(temp_str_buf);
173          return -1;
174       }
175
176       //TODO: Apply Strings to Multi Languange
177       elm_object_text_set( popup, _("No Theme Contents") );
178       evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL);
179
180       elm_popup_timeout_set( popup, POPUP_ALERT_TIMOUT_DURATION );
181       evas_object_smart_callback_add( popup, "response", _setting_theme_def_response_cb, NULL );
182       evas_object_show( popup );
183
184       eina_strbuf_free(temp_str_buf);
185       return -1;
186    }
187
188    // Read File
189    while( !feof( fp ) ) {
190       char temp_buffer[ SETTING_THEME_NAME_MAX_LEN ] = {0,};
191       fgets( temp_buffer, SETTING_THEME_NAME_MAX_LEN, fp );
192       index_list = eina_list_append( index_list, strdup(temp_buffer));
193    }
194
195    fclose(fp);
196
197    // Parsing
198    EINA_LIST_FOREACH( index_list, elist, meta_theme ) {
199
200       char *ptr;
201       char *meta = strtok_r( meta_theme, "=", &ptr);
202
203       if(meta) {
204
205          char *theme = strtok_r( NULL, "\n", &ptr);
206          if( theme == NULL ) continue;
207
208          if( !strncmp( DOWNLOAD_THEME_ICON_THEME_KEYWORD,
209                   meta,
210                   strlen( DOWNLOAD_THEME_ICON_THEME_KEYWORD)) ) {
211
212             ugd->theme.icon_theme.ext = 1;
213             strncpy(ugd->theme.icon_theme.name,theme,strlen(theme));
214
215          }
216          else if( !strncmp( DOWNLOAD_THEME_BOOT_ANIMATOR_THEME_KEYWORD,
217                   meta,
218                   strlen( DOWNLOAD_THEME_BOOT_ANIMATOR_THEME_KEYWORD)) ) {
219             ugd->theme.boot_ani_theme.ext = 1;
220             strncpy(ugd->theme.boot_ani_theme.name,theme,strlen(theme));
221          }
222          else if( !strncmp( DOWNLOAD_THEME_KEY_SOUND_THEME_KEYWORD,
223                   meta,
224                   strlen( DOWNLOAD_THEME_KEY_SOUND_THEME_KEYWORD )) ) {
225             ugd->theme.key_snd_theme.ext = 1;
226             strncpy(ugd->theme.key_snd_theme.name,theme,strlen(theme));
227
228          }
229          else if( !strncmp( DOWNLOAD_THEME_EFL_THEME_KEYWORD,
230                   meta,
231                   strlen( DOWNLOAD_THEME_EFL_THEME_KEYWORD ) ) ) {
232             ugd->theme.efl_theme.ext = 1;
233             strncpy(ugd->theme.efl_theme.name,theme,strlen(theme));
234
235          }
236          else if( !strncmp( DOWNLOAD_THEME_GTK_THEME_KEYWORD,
237                   meta,
238                   strlen( DOWNLOAD_THEME_GTK_THEME_KEYWORD ) ) ) {
239             ugd->theme.gtk_theme.ext = 1;
240             strncpy(ugd->theme.gtk_theme.name,theme,strlen(theme));
241          }
242          else if( !strncmp( DOWNLOAD_THEME_SCREEN_IMG_THEME_KEYWORD,
243                   meta,
244                   strlen( DOWNLOAD_THEME_SCREEN_IMG_THEME_KEYWORD ) ) ) {
245             ugd->theme.screen_image_theme.ext = 1;
246             strncpy(ugd->theme.screen_image_theme.name,theme,strlen(theme));
247
248          }
249          else if( !strncmp( DOWNLOAD_THEME_FONT_THEME_KEYWORD,
250                   meta,
251                   strlen( DOWNLOAD_THEME_FONT_THEME_KEYWORD )) ) {
252             ugd->theme.font_theme.ext = 1;
253             strncpy(ugd->theme.font_theme.name,theme,strlen(theme));
254          }
255          else if( !strncmp( DOWNLOAD_THEME_VIBRATION_THEME_KEYWORD,
256                   meta,
257                   strlen( DOWNLOAD_THEME_VIBRATION_THEME_KEYWORD )) ) {
258             ugd->theme.vibrate_theme.ext = 1;
259             strncpy(ugd->theme.vibrate_theme.name,theme,strlen(theme));
260          }
261       }
262    }
263
264    // clear
265    eina_strbuf_free(temp_str_buf);
266
267    EINA_LIST_FOREACH( index_list, elist, meta_theme ) {
268       index_list = eina_list_remove( index_list, meta_theme );
269       free( meta_theme );
270    }
271    return 0;
272 }
273
274 static Evas_Object* _create_naviframe( Evas_Object* parent )
275 {
276    if( parent == NULL ) return NULL;
277
278    Evas_Object *nf = elm_naviframe_add( parent );
279    evas_object_show( nf );
280
281    return nf;
282 }
283
284 static void _remove_files_in_dir( const char *folder_path )
285 {
286    struct stat statbuf;
287    char path_buf[ PATH_MAX ];
288    DIR* dp = NULL;
289    struct dirent *entry = NULL;
290    char *mime = NULL;
291    char *splitter = NULL;
292    char *env = getenv( "UI_IDLECAPTURE_IMG_TYPE" );
293
294    if( !env ) {
295       return ;
296    }
297
298    dp = opendir( folder_path );
299
300    if( dp == 0 ) {
301       return ;
302    }
303
304    if( chdir( folder_path ) != 0 ) {
305       fprintf( stderr, "Failed to change directory!\n" );
306    }
307
308    while( ( entry = readdir( dp ) ) != NULL ) {
309
310       stat( entry->d_name, &statbuf );
311
312       strcpy( path_buf, folder_path );
313
314       if( path_buf[ strlen( path_buf ) - 1 ]  != '/' ) {
315          strcat( path_buf, "/" );
316       }
317
318       strcat( path_buf, entry->d_name );
319
320       //case of directory
321       if( S_ISDIR( statbuf.st_mode ) ) {
322
323          if( strcmp( ".", entry->d_name ) == 0 || strcmp( "..", entry->d_name ) == 0 ) {
324             continue;
325          }
326
327          _remove_files_in_dir( path_buf );
328          continue;
329          //case of file
330       }else {
331          //Check is it jpeg type.
332          mime = (char *) efreet_mime_type_get( path_buf );
333
334          if( mime == 0 ) {
335             continue;
336          }
337
338          while( (splitter = strpbrk( mime, "/" )) ) {
339             if( strncmp( mime, env, splitter - mime ) == 0 ) {
340                unlink( path_buf );
341                continue;
342             }else {
343                mime = ++splitter;
344             }
345          }
346
347          if( strncmp( mime, env, strlen( mime ) ) == 0 ) {
348             unlink( path_buf );
349          }
350       }
351
352    }
353
354    if( chdir( ".." ) != 0 ) {
355       fprintf( stderr, "Failed to change directory!\n" );
356    }
357
358    closedir( dp );
359 }
360
361 static int _strncmp( const char *s1, const char *s2)
362 {
363    const char *longer = NULL;
364    const char *shorter = NULL;
365
366    if( strlen( s1 ) > strlen ( s2 ) ) {
367       longer = s1;
368       shorter = s2;
369    } else {
370       longer = s2;
371       shorter = s1;
372    }
373
374    return strncmp( longer, shorter, strlen( longer ) );
375 }
376
377 static void _get_default_theme_list( const char *folder_path, Eina_List **theme_list )
378 {
379    struct stat statbuf;
380    char path_buf[ PATH_MAX ];
381    DIR* dp = NULL;
382    struct dirent *entry = NULL;
383
384    dp = opendir( folder_path );
385
386    if( dp == 0 ) {
387       return ;
388    }
389
390    if( chdir( folder_path ) != 0 ) {
391       fprintf( stderr, "Failed to change directory!\n" );
392    }
393
394    while( ( entry = readdir( dp ) ) != NULL ) {
395
396       stat( entry->d_name, &statbuf );
397       strcpy( path_buf, folder_path );
398
399       if( path_buf[ strlen( path_buf ) - 1 ]  != '/' ) {
400          strcat( path_buf, "/" );
401       }
402
403       strcat( path_buf, entry->d_name );
404
405       //case of directory
406       if( S_ISDIR( statbuf.st_mode ) ) {
407
408          if( strcmp( ".", entry->d_name ) == 0 || strcmp( "..", entry->d_name ) == 0 ) {
409             continue;
410          }
411
412          _get_default_theme_list( path_buf, theme_list );
413          continue;
414
415          //case of file
416       }else {
417          //TODO: TEMPORARY COMPARE. SHOULD BE REMOVED!
418          if( !_strncmp( entry->d_name, "tizen.edj") ||
419                !_strncmp( entry->d_name, "tizen-black.edj") ||
420                !_strncmp( entry->d_name, "default.edj") ||
421                !_strncmp( entry->d_name, "default-desktop.edj") ) {
422             continue;
423          }
424
425          struct ug_theme_info *new_info = (struct ug_theme_info*)calloc(1,sizeof(struct ug_theme_info));
426          new_info->type = THEME_TYPE_DEFAULT;
427          new_info->name = strndup(entry->d_name, strpbrk( entry->d_name, ".") - entry->d_name );
428
429          *theme_list = eina_list_append( *theme_list, new_info );
430
431       }
432    }
433
434    if( chdir( ".." ) != 0 ) {
435       fprintf( stderr, "Failed to change directory!\n" );
436    }
437
438    closedir( dp );
439 }
440
441 static void _get_theme_list( const char *folder_path, Eina_List **theme_list )
442 {
443    struct stat statbuf;
444    char path_buf[ PATH_MAX ];
445    DIR* dp = NULL;
446    struct dirent *entry = NULL;
447
448    dp = opendir( folder_path );
449
450    if( dp == 0 ) {
451       return ;
452    }
453
454    if( chdir( folder_path ) != 0 ) {
455       fprintf( stderr, "Failed to change directory!\n" );
456    }
457
458    while( ( entry = readdir( dp ) ) != NULL ) {
459
460       stat( entry->d_name, &statbuf );
461
462       strcpy( path_buf, folder_path );
463
464       if( path_buf[ strlen( path_buf ) - 1 ]  != '/' ) {
465          strcat( path_buf, "/" );
466       }
467
468       strcat( path_buf, entry->d_name );
469
470       //in case of directory, add folder name to list.
471       if( S_ISDIR( statbuf.st_mode ) ) {
472
473          if( strcmp( ".", entry->d_name ) == 0 || strcmp( "..", entry->d_name ) == 0 ) {
474             continue;
475          }
476
477          struct ug_theme_info *new_info = (struct ug_theme_info*)calloc(1,sizeof(struct ug_theme_info));
478          new_info->type = THEME_TYPE_DOWNLOAD;
479          new_info->name = strdup(entry->d_name);
480          *theme_list = eina_list_append( *theme_list, new_info);
481       }
482    }
483    closedir( dp );
484 }
485
486 static int _delete_idle_imgs()
487 {
488    int ret = 0;
489    char *env = getenv( "UI_IDLECAPTURE_PATH" );
490
491    if( efreet_mime_init() == 0 ) {
492       return ret;
493    }
494
495    if(!env) {
496       _remove_files_in_dir( IDLE_IMG_PATH );
497    }else {
498       _remove_files_in_dir( env );
499    }
500
501    efreet_mime_shutdown();
502
503    return ret;
504 }
505
506 static int _selected_theme_idx_get()
507 {
508    Eina_List *elist = NULL;
509    struct ug_theme_info *theme_info = NULL;
510
511    // set selected theme
512    char *theme_name = vconf_get_str(SETTING_THEME_SELECTED_THEME);
513    int idx = 0;
514
515    EINA_LIST_FOREACH( gtheme_list, elist, theme_info ) {
516
517       if( _strncmp( theme_info->name, theme_name ) == 0 ) {
518          FREE(theme_name);
519          return idx;
520       }
521       idx++;
522    }
523    FREE(theme_name);
524    return -1;
525 }
526
527 static int exit_apps_iterfunc( const aul_app_info *info, void *data )
528 {
529    if( !info  || !info->pkg_name) return 0;
530
531    char *except_pkgs = (char *) getenv("SETTING_THEME_EXCEPT_PKGS");
532
533    if( except_pkgs ) {
534
535         //TODO: should remove pkgs here!!
536         //It can be skipped setting app by using aul with pid.
537
538    }else {
539         char* curr_menu = vconf_get_str("db/menuscreen/pkgname");
540
541         //TODO: Temporary comparison. Please remove this and implement above.
542         if( !_strncmp(info->pkg_name, "com.samsung.menu-screen") ||
543             !_strncmp(info->pkg_name, "com.samsung.setting") ||
544             !_strncmp(info->pkg_name, "com.samsung.live-magazine") ||
545             !_strncmp(info->pkg_name, "com.samsung.live-data-provider") ||
546             !_strncmp(info->pkg_name, "com.samsung.quickpanel") ||
547             !_strncmp(info->pkg_name, "com.samsung.vtmain") ||
548             !_strncmp(info->pkg_name, "com.samsung.call") ||
549             !_strncmp(info->pkg_name, curr_menu) ) {
550            FREE(curr_menu);
551            return 0;
552         }
553
554         FREE(curr_menu);
555    }
556
557    aul_terminate_pid( info->pid );
558
559    return 0;
560 }
561
562 static void _popup_default_theme_response_no_cb( void *data, Evas_Object *obj, void *event_info )
563 {
564       return;
565 }
566
567 static void _popup_default_theme_response_yes_cb( void *data, Evas_Object *obj, void *event_info )
568 {
569    Item_Data *item_data = (Item_Data *)data;
570    if(item_data == NULL) return;
571
572    struct ug_theme_info *theme_info = NULL;
573    theme_info = eina_list_nth(gtheme_list, item_data->idx);
574
575    View_Data *vd = (View_Data *)evas_object_data_get(elm_object_item_widget_get(item_data->it), "view_data");
576    if(vd == NULL) return;
577
578    elm_radio_value_set(rdg, item_data->idx);
579
580    // Change EFL Theme
581    Eina_Strbuf* efl_path = eina_strbuf_new();
582    eina_strbuf_append_printf( efl_path, "%s/%s.edj",
583                DEFAULT_THEME_FOLDER_PATH,
584                item_data->label);
585    elm_theme_set(NULL, eina_strbuf_string_get(efl_path));
586    elm_config_all_flush();
587    vconf_set_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR, eina_strbuf_string_get(efl_path) );
588    eina_strbuf_free(efl_path);
589
590    // Change Selected Theme Value
591    vconf_set_str(SETTING_THEME_SELECTED_THEME, item_data->label);
592
593    _delete_idle_imgs();
594    aul_app_get_running_app_info( exit_apps_iterfunc, NULL );
595    elm_exit();
596 }
597
598 static void _cancel_button_clicked(void *data, Evas_Object *obj, void *event_info)
599 {
600    if (!data) return;
601    Evas_Object *nf = (Evas_Object *) data;
602    elm_naviframe_item_pop(nf);
603 }
604
605 static void _done_button_clicked(void *data, Evas_Object *obj, void *event_info)
606 {
607    Evas_Object *btn1, *btn2;
608    Item_Data *item_data = (Item_Data *)data;
609    if(item_data == NULL) return;
610
611    struct ug_theme_info *theme_info = NULL;
612    theme_info = eina_list_nth(gtheme_list, item_data->idx);
613
614    View_Data *vd = (View_Data *)evas_object_data_get(elm_object_item_widget_get(item_data->it), "view_data");
615    if(vd == NULL) return;
616
617    //TODO: Test Code Should be removed - View_Data and && item_data->idx <= vd->default_theme_count
618    if (item_data->idx != _selected_theme_idx_get() && item_data->idx < vd->default_theme_count) {
619
620       if (THEME_TYPE_DEFAULT == theme_info->type){
621          // Show popup
622          Evas_Object *popup = elm_popup_add( vd->nf );
623          if( popup == NULL ) {
624               return ;
625          }
626
627          //TODO: Apply Multi Lanaguage to this string.
628          elm_object_text_set( popup, _("All Apps will be closed<br> to change theme") );
629
630          btn1 = elm_button_add(popup);
631          elm_object_text_set(btn1, _("IDS_COM_POP_YES"));
632          elm_object_part_content_set(popup, "button1", btn1);
633          evas_object_smart_callback_add(btn1, "clicked", _popup_default_theme_response_yes_cb, popup);
634
635          btn2 = elm_button_add(popup);
636          elm_object_text_set(btn2, _("IDS_COM_POP_NO"));
637          elm_object_part_content_set(popup, "button2", btn2);
638          evas_object_smart_callback_add(btn2, "clicked", _popup_default_theme_response_no_cb, popup);
639
640          evas_object_show( popup );
641       }
642
643       //TODO: Download Winset Setting
644 #if 0
645       else {
646          if (_load_index_file(ugd,theme_info) == 0) {
647             Eina_Strbuf* efl_path = eina_strbuf_new();
648             eina_strbuf_append_printf( efl_path, "%s/%s/%s/%s.edj",
649                   DOWNLOAD_THEME_FOLDER_PATH,
650                   theme_info->name,
651                   DOWNLOAD_THEME_EFL_FOLDER_NAME,
652                   ugd->theme.efl_theme.name);
653             vconf_set_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR, eina_strbuf_string_get(efl_path));
654             elm_theme_set(NULL, eina_strbuf_string_get(efl_path));
655             elm_config_all_flush();
656             eina_strbuf_free(efl_path);
657          }
658       }
659 #endif
660
661    }
662
663 }
664
665 // This is called when check box status is changed
666 static void _item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
667 {
668    Item_Data *item_data = (Item_Data *)data;
669    View_Data *vd = (View_Data *)evas_object_data_get(elm_object_item_widget_get(item_data->it), "view_data");
670    if (vd == NULL) return;
671
672    if (item_data->checked) vd->checked_count++;
673    else vd->checked_count--;
674
675    // update select all check button
676    if (vd->select_all_layout) {
677       if ((vd->total_count - vd->default_theme_count) == vd->checked_count)
678          vd->select_all_checked = EINA_TRUE;
679       else
680          vd->select_all_checked = EINA_FALSE;
681
682       elm_check_state_pointer_set(vd->select_all_checkbox, &vd->select_all_checked);
683    }
684 }
685
686 // FIXME: Need proper method.
687 // FIXME: This would be only available for our theme but not 3rd parties'
688 static char* _rename_theme(const char * origin)
689 {
690    if ( !_strncmp(origin, "tizen-hd") ) {
691      return strdup("White");
692    } else if ( !_strncmp(origin, "tizen-black-hd") ) {
693       return strdup("Black");
694    }
695    else return strdup(origin);
696 }
697
698 static void _reveal_button_clicked(void *data, Evas_Object *obj, void *event_info)
699 {
700    char *nf_title;
701    Evas_Object *cbar;
702    Evas_Object *cancel_btn;
703    Evas_Object *done_btn;
704    Evas_Object *nf;
705    Evas_Object *box;
706    Elm_Object_Item *ti;
707    Item_Data *item_data = (Item_Data *)data;
708    if (item_data == NULL) return;
709
710    View_Data *vd = (View_Data *)evas_object_data_get(elm_object_item_widget_get(item_data->it), "view_data");
711    if (vd == NULL) return;
712
713    nf = vd->nf;
714
715    // Create Controlbar
716    cbar = elm_toolbar_add(nf);
717    if (cbar == NULL) return;
718    elm_object_style_set(cbar, "naviframe");
719
720    cancel_btn = elm_button_add(cbar);
721    elm_object_style_set(cancel_btn, "naviframe_control/default");
722    evas_object_size_hint_align_set(cancel_btn, EVAS_HINT_FILL, 0.5);
723    elm_object_text_set(cancel_btn, _("Cancel"));
724    evas_object_show(cancel_btn);
725    evas_object_smart_callback_add(cancel_btn, "clicked", _cancel_button_clicked, nf);
726
727    done_btn = elm_button_add(cbar);
728    elm_object_style_set(done_btn, "naviframe_control/default");
729    evas_object_size_hint_align_set(done_btn, EVAS_HINT_FILL, 0.5);
730    elm_object_text_set(done_btn, _("Done"));
731    evas_object_show(done_btn);
732    evas_object_smart_callback_add(done_btn, "clicked", _done_button_clicked, item_data);
733
734    // Disable Button, If Currently Set
735    char *theme_name = vconf_get_str(SETTING_THEME_SELECTED_THEME);
736    if( _strncmp( item_data->label, theme_name ) == 0 ) {
737       elm_object_disabled_set(done_btn, 1);
738    }
739    FREE(theme_name);
740
741    // For Consistent Look
742    ti = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
743    elm_object_item_part_content_set(ti, "object", cancel_btn);
744    ti = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
745    elm_object_item_part_content_set(ti, "object", done_btn);
746
747    nf_title = _rename_theme(item_data->label);
748
749    box = elm_box_add(nf);
750    evas_object_show(box);
751
752    // TODO: Preview Image Should Get From Theme
753    if (item_data->idx < vd->default_theme_count) {
754
755       Evas_Object* icon;
756       icon = elm_icon_add(nf);
757
758       char* fn;
759       if (!_strncmp(item_data->label, "tizen-hd"))
760          fn = "tizen";
761       else if (!_strncmp(item_data->label, "tizen-black-hd"))
762          fn = "tizen-black";
763       else
764          fn = item_data->label;
765
766       Eina_Strbuf* efl_path = eina_strbuf_new();
767       eina_strbuf_append_printf( efl_path, "%s/%s.png",
768             IMG_DIR,
769             fn);
770
771       elm_icon_file_set(icon, eina_strbuf_string_get(efl_path), NULL);
772       elm_icon_resizable_set(icon, 0, 0);
773       evas_object_size_hint_align_set(icon, 0.5, 0.5);
774       elm_box_pack_end(box, icon);
775       evas_object_show(icon);
776
777       eina_strbuf_free(efl_path);
778    }
779
780    Elm_Object_Item *navi_it = elm_naviframe_item_push(nf, nf_title, NULL, NULL, box, NULL);
781    elm_object_item_part_content_set(navi_it, "optionheader", cbar);
782    FREE(nf_title);
783
784    // Remove Prev Button
785    Evas_Object *prev_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
786    evas_object_del(prev_btn);
787 }
788
789 static void _gl_sel( void *data, Evas_Object *obj, void *event_info)
790 {
791    Item_Data *item_data;
792    Elm_Object_Item *genlist_item = (Elm_Object_Item *) event_info;
793    if( genlist_item == NULL ) return;
794
795    elm_genlist_item_selected_set(genlist_item, EINA_FALSE);
796    item_data = elm_object_item_data_get(genlist_item);
797    _done_button_clicked(item_data, NULL, NULL);
798 }
799
800 static char* _gl_label_get(void *data, Evas_Object *obj, const char *part)
801 {
802    Item_Data *item_data = (Item_Data *) data;
803    if(item_data == NULL) return NULL;
804
805    if( strcmp(part, "elm.text") == 0 ) {
806       return _rename_theme(item_data->label);
807    }
808    return NULL;
809 }
810
811 Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group) {
812    Evas_Object *eo;
813    int r;
814
815    eo = elm_layout_add(parent);
816    if (eo) {
817       r = elm_layout_file_set(eo, file, group);
818       if (!r) {
819          evas_object_del(eo);
820          return NULL;
821       }
822    }
823
824    return eo;
825 }
826
827 static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
828 {
829    if(obj == NULL) return NULL;
830
831    Item_Data *item_data = (Item_Data *) data;
832    if(item_data == NULL) return NULL;
833
834    Evas_Object *icon;
835
836    if (!elm_genlist_decorate_mode_get(obj)) {
837       if ( !strncmp( part, "elm.icon.1", strlen(part) ) ) {
838          // radio button
839          icon = elm_radio_add(obj);
840          elm_radio_state_value_set(icon, (int) item_data->idx);
841          evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
842          elm_radio_group_add( icon, rdg );
843
844          // For avoidng user click
845          Evas_Object* fake_icon = _load_edj(obj, SETTING_THEME_EDJ, "fake_icon");
846          elm_object_part_content_set(fake_icon, "icon", icon);
847
848          return fake_icon;
849       } else if ( !strncmp( part, "elm.icon.2", strlen(part) ) ) {
850          // preview button
851          icon = elm_button_add(obj);
852          elm_object_style_set(icon, "reveal");
853          evas_object_smart_callback_add(icon, "clicked", _reveal_button_clicked, item_data);
854          evas_object_propagate_events_set(icon, EINA_FALSE);
855          return icon;
856       }
857    } else {
858       if (!strcmp(part, "elm.edit.icon.1")) {  // swallow checkbox or radio button
859          icon = elm_check_add(obj);
860          elm_check_state_pointer_set(icon, &item_data->checked);
861          evas_object_smart_callback_add(icon, "changed", _item_check_changed_cb, item_data);
862          return icon;
863       }
864    }
865    return NULL;
866 }
867
868 static void _clear_theme_list(Eina_List *theme_list)
869 {
870    Eina_List *elist = NULL;
871    struct ug_theme_info  *theme_info = NULL;
872    EINA_LIST_FOREACH( theme_list, elist, theme_info ) {
873       theme_list = eina_list_remove( theme_list, theme_info );
874       free( theme_info->name );
875       free( theme_info );
876    }
877 }
878
879 static void _base_object_del_cb(void * data, Evas *e, Evas_Object *obj, void *event_info)
880 {
881    struct ug_data *ugd = (struct ug_data *) data;
882    ugd->base = NULL;
883 }
884
885 static void _back_button_clicked( void *data, Evas_Object *obj, void *event_info )
886 {
887    struct ug_data * ugd = (struct ug_data *) data;
888
889    ug_destroy_me(ugd->ug);
890 }
891
892 static void _check_select_all(View_Data *vd)
893 {
894    Item_Data *it_data;
895    Elm_Object_Item *it;
896
897    if (vd->select_all_checked) vd->checked_count = (vd->total_count - vd->default_theme_count);
898    else vd->checked_count = 0;
899
900    it = elm_genlist_first_item_get(vd->genlist);
901    while(it) {
902       it_data = elm_object_item_data_get(it);
903       if (it_data) it_data->checked = vd->select_all_checked;
904       it = elm_genlist_item_next_get(it);
905    }
906    // Update all realized items
907    elm_genlist_realized_items_update(vd->genlist);
908 }
909
910 static void _select_all_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
911 {
912    _check_select_all(data);
913 }
914
915 static void _genlist_to_normal(View_Data *data)
916 {
917    if (!data) return;
918    View_Data *vd = data;
919    Item_Data *item_data;
920    Evas_Object *genlist = vd->genlist;
921    Evas_Object *delete_btn = vd->delete_btn, *more_btn = vd->more_btn;
922    Elm_Object_Item *it, *ti;
923    Eina_List *elist = NULL;
924    struct ug_theme_info *theme_info = NULL;
925    int idx = 0;
926
927    // Change background color to default background color
928    elm_object_style_set(vd->bg, "group_list");
929
930    // Change button label
931    elm_object_text_set(delete_btn, _("Delete"));
932    elm_object_text_set(more_btn, _("More winsets"));
933
934    // Remove 'Select All' layout.
935    elm_box_unpack(vd->box, vd->select_all_layout);
936    evas_object_del(vd->select_all_layout);
937    vd->select_all_layout = NULL;
938
939    // Unset edit mode
940    elm_genlist_decorate_mode_set(genlist, EINA_FALSE);
941    elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
942
943    // Add Default Theme
944    idx = 0;
945    it = elm_genlist_first_item_get(genlist);
946    EINA_LIST_FOREACH( gtheme_list, elist, theme_info ) {
947       item_data = calloc(1, sizeof(Item_Data));
948       item_data->label = theme_info->name;
949       item_data->idx = idx;
950       if (it)
951          item_data->it = elm_genlist_item_insert_before(genlist, &itc, (void *) item_data, NULL, it, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
952       else {
953          item_data->it = elm_genlist_item_append(genlist, &itc, (void *) item_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
954       }
955
956       idx++;
957       if (idx >= vd->default_theme_count) break;
958    }
959
960    // Remove 'Delete' button
961    idx = 0;
962    it = elm_genlist_first_item_get(genlist);
963    while(it) {
964       idx++;
965       it = elm_genlist_item_next_get(it);
966    }
967
968    if (idx <= vd->default_theme_count) {
969       elm_object_item_del(vd->del_btn_item);
970       ti = elm_toolbar_item_prepend(vd->cbar, NULL, NULL, NULL, NULL);
971       elm_object_item_part_content_set(ti, "object", NULL);
972    }
973
974    // Change Genlist Item Class
975    idx = 0;
976    it = elm_genlist_item_prepend(genlist, &itc2, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
977    elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
978
979    it = elm_genlist_first_item_get(genlist);
980    while(it) {
981       if(idx != 0) {
982          elm_genlist_item_item_class_update(it, &itc);
983       }
984       it = elm_genlist_item_next_get(it);
985       ++idx;
986    }
987 }
988
989 static void _delete_button_clicked(void *data, Evas_Object *obj, void *event_info)
990 {
991    if (!data) return;
992    View_Data *vd = data;
993    Item_Data *item_data;
994    Evas_Object *genlist = vd->genlist, *layout, *check;
995    Evas_Object *delete_btn = vd->delete_btn, *more_btn = vd->more_btn;
996    Elm_Object_Item *it;
997    int idx = 0;
998
999    if (!elm_genlist_decorate_mode_get(genlist)) {
1000       // Genlist will be in Edit Mode
1001
1002       // Change background color to edit_mode color
1003       elm_object_style_set(vd->bg, "edit_mode");
1004
1005       // Change button label
1006       elm_object_text_set(delete_btn, _("Cancel"));
1007       elm_object_text_set(more_btn, _("Done"));
1008
1009       // Append 'Select All' layout
1010       layout = vd->select_all_layout = elm_layout_add(vd->box);
1011       elm_layout_theme_set(layout, "genlist", "item", "select_all/default");
1012       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
1013       evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1014
1015       check = vd->select_all_checkbox = elm_check_add(vd->select_all_layout);
1016       elm_check_state_pointer_set(check, &vd->select_all_checked);
1017       evas_object_smart_callback_add(check, "changed", _select_all_check_changed_cb, vd);
1018       elm_check_state_set(check, EINA_FALSE);
1019       vd->select_all_checked = EINA_FALSE;
1020       evas_object_propagate_events_set(check, EINA_FALSE);
1021       elm_object_part_content_set(layout, "elm.icon", check);
1022
1023       elm_object_part_text_set(vd->select_all_layout, "elm.text", "Select All");
1024       elm_box_pack_start(vd->box, vd->select_all_layout);
1025       evas_object_show(vd->select_all_layout);
1026
1027       // Delete Seperator Item
1028       it = elm_genlist_first_item_get(genlist);
1029       elm_object_item_del(it);
1030
1031       // Delete Default Theme Item
1032       idx = vd->default_theme_count;
1033       it = elm_genlist_first_item_get(genlist);
1034       while(it && idx > 0) {
1035          item_data = elm_object_item_data_get(it);
1036          it = elm_genlist_item_next_get(it);
1037
1038          if (item_data) {
1039             elm_object_item_del(item_data->it);
1040             idx--;
1041          }
1042       }
1043
1044       // Change Genlist Item Class
1045       it = elm_genlist_first_item_get(genlist);
1046       while(it) {
1047          elm_genlist_item_item_class_update(it, &edit_mode_itc);
1048          item_data = elm_object_item_data_get(it);
1049          item_data->checked = EINA_FALSE;
1050          it = elm_genlist_item_next_get(it);
1051       }
1052       vd->checked_count = 0;
1053
1054       elm_genlist_decorate_mode_set(genlist, EINA_TRUE);
1055    } else {
1056       // Genlist will be in Normal Mode
1057       _genlist_to_normal(vd);
1058    }
1059 }
1060
1061 static void response_cb(void *data, Evas_Object *obj, void *event_info)
1062 {
1063    if (obj != NULL)
1064       evas_object_del(obj);
1065 }
1066
1067 static void _more_button_clicked(void *data, Evas_Object *obj, void *event_info)
1068 {
1069    struct ug_data *ugd = (struct ug_data *) data;
1070    if (ugd == NULL) return;
1071
1072    View_Data *vd = ugd->vd;
1073    if (vd == NULL) return;
1074
1075    Item_Data *it_data;
1076    Elm_Object_Item *it;
1077    Evas_Object *genlist = vd->genlist;
1078
1079    if (!elm_genlist_decorate_mode_get(genlist)) {
1080       if(aul_launch_app("com.samsung.samsungapps", NULL) < 0) {
1081          // Error Handling, Cannot Launch Samsung Apps
1082          Evas_Object *popup = elm_popup_add(vd->nf);
1083          elm_object_text_set(popup, "Samsung Apps is not installed");
1084          evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL);
1085          elm_popup_timeout_set(popup, 3.0);
1086          evas_object_smart_callback_add(popup, "response", response_cb, NULL);
1087          evas_object_show(popup);
1088       }
1089    } else {
1090       // Done - Delete Selected Winset
1091       it = elm_genlist_first_item_get(genlist);
1092       while (it) {
1093          it_data = elm_object_item_data_get(it);
1094          it = elm_genlist_item_next_get(it);
1095
1096          if ((it_data) && (it_data->checked)) {
1097             elm_object_item_del(it_data->it);
1098             vd->total_count--;
1099             vd->checked_count--;
1100          }
1101       }
1102       _genlist_to_normal(vd);
1103    }
1104
1105 }
1106
1107 static void _set_genlist_item_styles(View_Data *vd)
1108 {
1109    itc.item_style = "dialogue/1text.2icon.2";
1110    itc.func.text_get = _gl_label_get;
1111    itc.func.content_get = _gl_icon_get;
1112    itc.func.state_get = NULL;
1113    itc.func.del = NULL;
1114    itc.decorate_item_style = "edit_default";
1115
1116    itc2.item_style = "dialogue/seperator";
1117    itc2.func.text_get = NULL;
1118    itc2.func.content_get = NULL;
1119    itc2.func.state_get = NULL;
1120    itc2.func.del = NULL;
1121
1122    edit_mode_itc.item_style = "1text";
1123    edit_mode_itc.func.text_get = _gl_label_get;
1124    edit_mode_itc.func.content_get = _gl_icon_get;
1125    edit_mode_itc.func.state_get = NULL;
1126    edit_mode_itc.func.del = NULL;
1127    edit_mode_itc.decorate_item_style = "edit_default";
1128 }
1129
1130 // Create genlist and append items
1131 static Evas_Object *_create_genlist(struct ug_data *ugd)
1132 {
1133    if( ugd == NULL ) return NULL;
1134    View_Data *vd = ugd->vd;
1135    Item_Data *item_data;
1136    Evas_Object *genlist;
1137
1138    // Create genlist
1139    genlist = elm_genlist_add(vd->nf);
1140    evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1141    evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1142
1143    // Get Default Theme
1144    Eina_List *theme_list = ugd->theme_list;
1145    _get_default_theme_list( DEFAULT_THEME_FOLDER_PATH, &theme_list);
1146    vd->default_theme_count = eina_list_count(theme_list);
1147
1148    // Get Download Theme
1149    _get_theme_list( DOWNLOAD_THEME_FOLDER_PATH , &theme_list );
1150
1151    //TODO: Test Code - START, Should be removed
1152 #if 0
1153    struct ug_theme_info *new_info_r = (struct ug_theme_info*)calloc(1,sizeof(struct ug_theme_info));
1154    new_info_r->type = THEME_TYPE_DOWNLOAD;
1155    new_info_r->name = strndup("Red", strlen("Red"));
1156    eina_list_append( theme_list, new_info_r );
1157
1158    struct ug_theme_info *new_info_g = (struct ug_theme_info*)calloc(1,sizeof(struct ug_theme_info));
1159    new_info_g->type = THEME_TYPE_DOWNLOAD;
1160    new_info_g->name = strndup("Green", strlen("Green"));
1161    eina_list_append( theme_list, new_info_g );
1162
1163    struct ug_theme_info *new_info_b = (struct ug_theme_info*)calloc(1,sizeof(struct ug_theme_info));
1164    new_info_b->type = THEME_TYPE_DOWNLOAD;
1165    new_info_b->name = strndup("Blue", strlen("Blue"));
1166    eina_list_append( theme_list, new_info_b );
1167 #endif
1168    //TODO: Test Code - END, Should be removed
1169    ugd->theme_list = theme_list;
1170    gtheme_list = eina_list_clone( ugd->theme_list );
1171
1172    Eina_List *elist = NULL;
1173    struct ug_theme_info *theme_info = NULL;
1174    int idx = 0;
1175
1176    item_data = calloc(1, sizeof(Item_Data));
1177    item_data->label = NULL;
1178    item_data->idx = idx;
1179    item_data->it = elm_genlist_item_append(genlist, &itc2, (void *) item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1180    elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1181
1182    EINA_LIST_FOREACH( gtheme_list, elist, theme_info ) {
1183       item_data = calloc(1, sizeof(Item_Data));
1184       item_data->label = theme_info->name;
1185       item_data->idx = idx;
1186       item_data->it = elm_genlist_item_append(genlist, &itc, (void *) item_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1187       idx++;
1188    }
1189
1190    evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1191    evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1192
1193    vd->total_count = idx;
1194
1195    // Check selected theme
1196    idx = _selected_theme_idx_get();
1197    if (idx < 0) return genlist;
1198
1199    // Create radio group
1200    rdg = elm_radio_add( genlist );
1201    elm_radio_value_set( rdg, idx );
1202
1203    return genlist;
1204 }
1205
1206 static Evas_Object *create_fullview( Evas_Object *parent, struct ug_data *ugd )
1207 {
1208    Evas_Object *cbar;
1209    Elm_Object_Item *ti;
1210
1211    if(parent == NULL) return NULL;
1212
1213    // Create layout data
1214    View_Data *vd;
1215    vd = calloc(1, sizeof(View_Data));
1216    ugd->vd = vd;
1217
1218    // Create layout
1219    Evas_Object *layout = _create_layout_main( parent, vd );
1220    if( layout == NULL ) return NULL;
1221
1222    vd->nf = _create_naviframe( layout );
1223    if( vd->nf == NULL ) {
1224       evas_object_del( layout );
1225       return NULL;
1226    }
1227    // Create Genlist
1228    _set_genlist_item_styles(vd);
1229    vd->genlist = _create_genlist(ugd);
1230
1231    // Need by Item Check Changed Callback , Reveal Button Clicked Callback
1232    evas_object_data_set(vd->genlist, "view_data", vd);
1233
1234    // Create Box
1235    vd->box = elm_box_add(vd->nf);
1236    evas_object_size_hint_weight_set(vd->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1237    evas_object_show(vd->box);
1238
1239    elm_box_pack_end(vd->box, vd->genlist);
1240    evas_object_show(vd->genlist);
1241
1242    elm_object_part_content_set( layout, "elm.swallow.content", vd->nf );
1243
1244    // Create Controlbar
1245    vd->cbar = cbar = elm_toolbar_add(vd->nf);
1246    if (cbar == NULL) return NULL;
1247    elm_object_style_set(cbar, "naviframe");
1248
1249    vd->more_btn = elm_button_add(cbar);
1250    elm_object_style_set(vd->more_btn, "naviframe_control/default");
1251    evas_object_size_hint_align_set(vd->more_btn, EVAS_HINT_FILL, 0.5);
1252    elm_object_text_set(vd->more_btn, _("More winsets"));
1253    evas_object_show(vd->more_btn);
1254    evas_object_smart_callback_add(vd->more_btn, "clicked", _more_button_clicked, ugd);
1255
1256    //If there is download winset, then enable delete button
1257    if(vd->default_theme_count < vd->total_count)
1258      {
1259         vd->delete_btn = elm_button_add(cbar);
1260         elm_object_style_set(vd->delete_btn, "naviframe_control/default");
1261         evas_object_size_hint_align_set(vd->delete_btn, EVAS_HINT_FILL, 0.5);
1262         elm_object_text_set(vd->delete_btn, _("Delete"));
1263         evas_object_show(vd->delete_btn);
1264         evas_object_smart_callback_add(vd->delete_btn, "clicked", _delete_button_clicked, vd);
1265         vd->del_btn_item = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
1266         elm_object_item_part_content_set(vd->del_btn_item, "object", vd->delete_btn);
1267      }
1268    else
1269      {
1270         ti = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
1271         elm_object_item_part_content_set(ti, "object", NULL);
1272      }
1273    ti = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
1274    elm_object_item_part_content_set(ti, "object", vd->more_btn);
1275
1276    Evas_Object *back_btn = elm_button_add( vd->nf );
1277    elm_object_style_set(back_btn, "naviframe/back_btn/default");
1278    evas_object_smart_callback_add( back_btn, "clicked", _back_button_clicked, ugd );
1279    Elm_Object_Item *navi_it = elm_naviframe_item_push( vd->nf, _("IDS_ST_BODY_THEME"), back_btn, NULL, vd->box, NULL );
1280
1281    // add controlbar to naviframe
1282    elm_object_item_part_content_set(navi_it, "optionheader", cbar);
1283    elm_object_item_signal_emit(navi_it, "elm,state,optionheader,instant_close", "");
1284
1285    evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _base_object_del_cb, ugd);
1286
1287    return layout;
1288 }
1289
1290 static Evas_Object *create_frameview(Evas_Object *parent, struct ug_data *ugd)
1291 {
1292    Evas_Object *base = NULL;
1293
1294    // Create Frame view
1295
1296    return base;
1297 }
1298
1299 static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle *data, void *priv)
1300 {
1301    Evas_Object *parent;
1302    struct ug_data *ugd;
1303    if (!ug || !priv)
1304       return NULL;
1305
1306    ugd = priv;
1307    ugd->ug = ug;
1308
1309    bindtextdomain(PKGNAME, MO_FILE_PATH);
1310
1311    parent = ug_get_parent_layout(ug);
1312    if (!parent)
1313       return NULL;
1314
1315    if (mode == UG_MODE_FULLVIEW)
1316       ugd->base = create_fullview(parent, ugd);
1317    else
1318       ugd->base = create_frameview(parent, ugd);
1319
1320    _parent = parent;
1321
1322    return ugd->base;
1323 }
1324
1325 static void on_start(struct ui_gadget *ug, bundle *data, void *priv)
1326 {
1327 }
1328
1329 static void on_pause(struct ui_gadget *ug, bundle *data, void *priv)
1330 {
1331
1332 }
1333
1334 static void on_resume(struct ui_gadget *ug, bundle *data, void *priv)
1335 {
1336
1337 }
1338
1339
1340 static void on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
1341 {
1342    struct ug_data *ugd;
1343
1344    if (!ug || !priv)
1345       return;
1346
1347    ugd = priv;
1348
1349    // Free View Data
1350    if (ugd->vd) {
1351       if (ugd->vd->bg) {
1352          evas_object_del(ugd->vd->bg);
1353          ugd->vd->bg = NULL;
1354       }
1355       evas_object_data_set(ugd->vd->genlist, "view_data", NULL);
1356       free(ugd->vd);
1357       ugd->vd = NULL;
1358    }
1359
1360    _clear_theme_list( ugd->theme_list );
1361    ugd->theme_list = NULL;
1362
1363    if( ugd->base ) {
1364       evas_object_del(ugd->base);
1365       ugd->base = NULL;
1366    }
1367
1368    eina_list_free( gtheme_list );
1369    gtheme_list = NULL;
1370
1371    if( rdg != NULL ) {
1372       evas_object_del( rdg );
1373       rdg = NULL;
1374    }
1375 }
1376
1377 static void on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
1378 {
1379 }
1380
1381 static void on_event(struct ui_gadget *ug, enum ug_event event, bundle *data, void *priv)
1382 {
1383    switch (event) {
1384       case UG_EVENT_LOW_MEMORY:
1385          break;
1386       case UG_EVENT_LOW_BATTERY:
1387          break;
1388       case UG_EVENT_LANG_CHANGE:
1389          break;
1390       case UG_EVENT_ROTATE_PORTRAIT:
1391          break;
1392       case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
1393          break;
1394       case UG_EVENT_ROTATE_LANDSCAPE:
1395          break;
1396       case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
1397          break;
1398       default:
1399          break;
1400    }
1401 }
1402
1403 static void on_key_event(struct ui_gadget *ug, enum ug_key_event event, bundle *data, void *priv)
1404 {
1405    if (!ug)
1406       return;
1407
1408    switch (event) {
1409       case UG_KEY_EVENT_END:
1410          ug_destroy_me(ug);
1411          break;
1412       default:
1413          break;
1414    }
1415 }
1416
1417 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
1418 {
1419    struct ug_data *ugd;
1420
1421    if (!ops)
1422       return -1;
1423
1424    ugd = calloc(1, sizeof(struct ug_data));
1425    if (!ugd)
1426       return -1;
1427
1428    ops->create = on_create;
1429    ops->start = on_start;
1430    ops->pause = on_pause;
1431    ops->resume = on_resume;
1432    ops->destroy = on_destroy;
1433    ops->message = on_message;
1434    ops->event = on_event;
1435    ops->key_event = on_key_event;
1436    ops->priv = ugd;
1437    ops->opt = UG_OPT_INDICATOR_ENABLE;
1438
1439    return 0;
1440 }
1441
1442 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
1443 {
1444    struct ug_data *ugd;
1445
1446    if (!ops)
1447       return;
1448
1449    ugd = ops->priv;
1450    if (ugd)
1451       free(ugd);
1452 }
1453
1454 // For Reset Operation
1455 UG_MODULE_API int setting_plugin_reset(bundle *data, void *priv)
1456 {
1457    //FIXME: Need to avoid hard coding for default theme name
1458    char *value = vconf_get_str(SETTING_THEME_SELECTED_THEME);
1459
1460    if (value && !strcmp(value, "tizen-black-hd"))
1461      {
1462         vconf_set_bool(SETTING_THEME_IS_THEME_CHANGED, 0);
1463      }
1464    else
1465      {
1466         vconf_set_bool(SETTING_THEME_IS_THEME_CHANGED, 1);
1467      }
1468
1469    FREE(value);
1470
1471    // Change Selected Theme Value
1472    vconf_set_str(SETTING_THEME_SELECTED_THEME, "tizen-black-hd");
1473
1474    // Change EFL Theme
1475    Eina_Strbuf* efl_path = eina_strbuf_new();
1476    eina_strbuf_append_printf( efl_path, "%s/tizen-black-hd.edj",
1477                DEFAULT_THEME_FOLDER_PATH);
1478    vconf_set_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR, eina_strbuf_string_get(efl_path) );
1479    eina_strbuf_free(efl_path);
1480
1481    _delete_idle_imgs();
1482    aul_app_get_running_app_info( exit_apps_iterfunc, NULL );
1483
1484    return 0;
1485 }