tizen 2.3 release
[apps/home/b2-clocksetting.git] / src / setting-reset.c
1 /*
2  * Copyright (c) 2010 Samsung Electronics, Inc.
3  * All rights reserved.
4  *
5  * This software is a confidential and proprietary information
6  * of Samsung Electronics, Inc. ("Confidential Information").  You
7  * shall not disclose such Confidential Information and shall use
8  * it only in accordance with the terms of the license agreement
9  * you entered into with Samsung Electronics.
10  */
11 /*
12  * setting-reset.c
13  *
14  *  Created on: Oct 10, 2013
15  *      Author: min-hoyun
16  */
17
18 #include "setting.h"
19 #include "setting-reset.h"
20 #include "util.h"
21
22
23 static void _remove_reset_popup(appdata * ad)
24 {
25         if( ad == NULL )
26                 return;
27         if( ad->popup ) {
28                 evas_object_del(ad->popup);
29                 ad->popup = NULL;
30         }
31 }
32
33 static void _response_cancel_cb(void *data, Evas_Object *obj, void *event_info)
34 {
35         appdata * ad = (appdata * )data;
36
37         _remove_reset_popup(ad);
38 }
39
40 static void _response_ok_cb(void *data, Evas_Object *obj, void *event_info)
41 {
42         appdata * ad = data;
43
44         _remove_reset_popup(ad);
45
46         /* call Factory-reset */
47         deviced_call_predef_action(PREDEF_FACTORY_RESET, 0, NULL);
48 }
49
50 void _reset_lange_changed(void *data, Evas_Object *obj, void *event_info)
51 {
52         DBG("Setting - _reset_lange_changed() is called!");
53
54         char buf[1024];
55         snprintf(buf, sizeof(buf), "<font_size=34>%s</font_size>",
56                         elm_entry_utf8_to_markup(_("IDS_ST_POP_ALL_DATA_WILL_BE_ERASED_FROM_GEAR_MEMORY_YOU_CAN_THEN_CONNECT_YOUR_GEAR_TO_ANOTHER_DEVICE")));
57         elm_object_text_set(obj, strdup(buf));
58 }
59
60 void _reset_popup_cb(void *data, Evas_Object *obj, void *event_info)
61 {
62         Evas_Object *popup = NULL;
63         Evas_Object *btn = NULL;
64         Evas_Object *scroller = NULL;
65         Evas_Object *label = NULL;
66
67         appdata *ad = (appdata *) data;
68         if( ad == NULL )
69                 return;
70
71         popup = elm_popup_add(ad->nf);
72         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73         elm_object_translatable_part_text_set(popup, "title,text", "IDS_ST_BODY_RESET_GEAR_ABB");
74
75         ad->popup = popup;
76
77         scroller = elm_scroller_add(popup);
78         evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79         elm_object_content_set(popup, scroller);
80         elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
81         elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
82         elm_object_style_set(scroller, "effect");
83         evas_object_show(scroller);
84
85         label = elm_label_add(scroller);
86         elm_object_style_set(label, "popup/default");
87         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
88
89         char buf[1024];
90
91         char * font_size_frame = "<font_size=34>%s</font_size>";
92         snprintf(buf, sizeof(buf)-1, font_size_frame, _("IDS_ST_POP_ALL_DATA_WILL_BE_ERASED_FROM_GEAR_MEMORY_YOU_CAN_THEN_CONNECT_YOUR_GEAR_TO_ANOTHER_DEVICE"));
93
94         char *txt = strdup(buf);
95         elm_object_text_set(label, txt);
96         free(txt);
97         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
98         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
99         evas_object_smart_callback_add(label, "language,changed", _reset_lange_changed, NULL);
100         elm_object_content_set(scroller, label);
101         evas_object_show(label);
102
103
104         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, setting_popup_back_cb, ad);
105
106         btn = elm_button_add(popup);
107         elm_object_style_set(btn, "popup");
108         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109         elm_object_translatable_text_set(btn, "IDS_COM_SK_CANCEL_A");
110         elm_object_part_content_set(popup, "button1", btn);
111         evas_object_smart_callback_add(btn, "clicked", _response_cancel_cb, ad);
112
113         btn = elm_button_add(popup);
114         elm_object_style_set(btn, "popup");
115         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116         elm_object_translatable_text_set(btn, "IDS_WNOTI_BUTTON_OK_ABB2");
117         elm_object_part_content_set(popup, "button2", btn);
118         evas_object_smart_callback_add(btn, "clicked", _response_ok_cb, ad);
119
120         evas_object_show(popup);
121 }