tizen 2.0beta
[apps/native/ug-wifi-direct.git] / ug-wifidirect / src / wfd_ug_about_view.c
1 /*
2 *  WiFi-Direct UG
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #include <libintl.h>
21
22 #include <assert.h>
23 #include <glib.h>
24
25 #include <Elementary.h>
26 #include <vconf.h>
27 #include <ui-gadget-module.h>
28 #include <wifi-direct.h>
29
30 #include "wfd_ug.h"
31 #include "wfd_ug_view.h"
32 #include "wfd_client.h"
33
34 static Elm_Genlist_Item_Class itc;
35
36 static char *_wfd_gl_label_help_dialogue_get(void *data, Evas_Object *obj, const char *part)
37 {
38         DBG(LOG_VERBOSE, "Adding text");
39
40         if (!strcmp(part, "elm.text.2")) {
41                 return strdup(IDS_WFD_BODY_ABOUT_WIFI);
42         }
43         return NULL;
44 }
45
46 static Evas_Object *_wfd_gl_help_icon_get(void *data, Evas_Object * obj, const char *part)
47 {
48     __FUNC_ENTER__;
49
50     DBG(LOG_VERBOSE, "Current part: %s\n", part);
51     Evas_Object *label = NULL;
52     char content[1024] = {0};
53
54     label = elm_label_add(obj);
55     snprintf(content, 1024, "<color=#7C7C7CFF><font_size=32>%s</font_size></color>", IDS_WFD_BODY_ABOUT_WIFI);
56     elm_label_line_wrap_set(label, ELM_WRAP_WORD);
57     elm_object_text_set(label, content);
58     evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
59     evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0);
60     evas_object_show(label);
61
62     __FUNC_EXIT__;
63     return label;
64 }
65
66 void _about_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info)
67 {
68     __FUNC_ENTER__;
69     struct ug_data *ugd = (struct ug_data*) data;
70
71     if(!ugd)
72     {
73         DBG(LOG_ERROR, "The param is NULL\n");
74         return;
75     }
76
77    elm_naviframe_item_pop(ugd->naviframe);
78
79     __FUNC_EXIT__;
80     return;
81 }
82
83 void _wifid_create_about_view(struct ug_data *ugd)
84 {
85
86     Evas_Object *back_btn = NULL;
87     Elm_Object_Item *navi_item = NULL;
88     Evas_Object *control_bar = NULL;
89     Elm_Object_Item *item = NULL;
90     Evas_Object *genlist = NULL;
91     if(ugd == NULL)
92     {
93         DBG(LOG_ERROR, "Incorrect parameter(NULL)");
94         return;
95     }
96
97     genlist = elm_genlist_add(ugd->naviframe);
98     elm_object_style_set(genlist, "dialogue");
99
100     DBG(LOG_VERBOSE, "creating about view");
101     elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
102 #if 0
103     itc.item_style = "multiline/1text";
104     itc.func.text_get = _wfd_gl_label_help_dialogue_get;
105     itc.func.content_get = NULL;
106 #else
107     itc.item_style = "1icon";
108     itc.func.text_get = NULL;
109     itc.func.content_get = _wfd_gl_help_icon_get;
110 #endif
111     itc.func.state_get = NULL;
112     itc.func.del = NULL;
113     back_btn = elm_button_add(ugd->naviframe);
114     elm_object_style_set(back_btn, "naviframe/back_btn/default");
115     evas_object_smart_callback_add(back_btn, "clicked", _about_view_back_btn_cb, (void*) ugd);
116     elm_object_focus_allow_set(back_btn, EINA_FALSE);
117
118     item = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
119     elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
120     evas_object_show(genlist);
121     navi_item = elm_naviframe_item_push(ugd->naviframe, IDS_WFD_TITLE_ABOUT_WIFI, back_btn, NULL, genlist, NULL);
122
123     control_bar = elm_toolbar_add(ugd->naviframe);
124     elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
125     evas_object_show(control_bar);
126     elm_object_item_part_content_set(navi_item, "controlbar", control_bar);
127
128 }