4 #include <Elementary.h>
11 #include "callscreen.h"
13 static Evas_Object *win = NULL;
14 static Evas_Object *main_layout = NULL;
15 static Evas_Object *keypad = NULL;
16 static Evas_Object *contacts = NULL;
17 static Evas_Object *history = NULL;
18 static Evas_Object *cs = NULL;
19 static Evas_Object *flip = NULL;
20 static char def_theme[PATH_MAX] = "";
22 /* XXX elm_flip should just do the right thing, but it does not */
23 static Eina_Bool in_call = EINA_FALSE;
24 static Eina_Bool in_flip_anim = EINA_FALSE;
26 Evas_Object *gui_layout_add(Evas_Object *parent, const char *style)
28 Evas_Object *layout = elm_layout_add(parent);
29 if (!elm_layout_theme_set(layout, "layout", "dialer", style)) {
30 CRITICAL("No theme for 'elm/layout/dialer/%s' at %s",
32 evas_object_del(layout);
38 static void _gui_show(Evas_Object *o)
41 elm_object_signal_emit(main_layout, "show,keypad", "gui");
42 else if (o == contacts)
43 elm_object_signal_emit(main_layout, "show,contacts", "gui");
44 else if (o == history)
45 elm_object_signal_emit(main_layout, "show,history", "gui");
46 elm_object_focus_set(o, EINA_TRUE);
49 static void _popup_close(void *data, Evas_Object *bt __UNUSED__, void *event __UNUSED__)
51 Evas_Object *popup = data;
52 evas_object_del(popup);
55 void gui_simple_popup(const char *title, const char *message)
57 Evas_Object *p = elm_popup_add(win);
60 evas_object_size_hint_weight_set(p, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61 elm_object_text_set(p, message);
62 elm_object_part_text_set(p, "title,text", title);
64 bt = elm_button_add(p);
65 elm_object_text_set(bt, "Close");
66 elm_object_part_content_set(p, "button1", bt);
67 evas_object_smart_callback_add(bt, "clicked", _popup_close, p);
71 void gui_activate(void)
74 elm_win_activate(win);
75 evas_object_show(win);
78 void gui_number_set(const char *number, Eina_Bool auto_dial)
81 keypad_number_set(keypad, number, auto_dial);
84 void gui_call_enter(void)
92 in_flip_anim = EINA_TRUE;
93 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
94 elm_object_focus_set(cs, EINA_TRUE);
97 void gui_call_exit(void)
101 in_call = EINA_FALSE;
104 in_flip_anim = EINA_TRUE;
105 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
106 elm_object_focus_set(cs, EINA_FALSE);
109 static void _gui_call_sync(void *data __UNUSED__, Evas_Object *o __UNUSED__,
110 void *event_info __UNUSED__)
112 Eina_Bool showing_call = !elm_flip_front_visible_get(flip);
114 if (showing_call ^ in_call) {
115 DBG("Flip back to sync");
116 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
117 elm_object_focus_set(cs, in_call);
119 in_flip_anim = EINA_FALSE;
122 static void _on_clicked(void *data __UNUSED__, Evas_Object *o __UNUSED__,
123 const char *emission, const char *source __UNUSED__)
125 DBG("signal: %s", emission);
127 EINA_SAFETY_ON_FALSE_RETURN(eina_str_has_prefix(emission, "clicked,"));
128 emission += strlen("clicked,");
130 if (strcmp(emission, "keypad") == 0)
132 else if (strcmp(emission, "contacts") == 0)
134 else if (strcmp(emission, "history") == 0)
138 Eina_Bool gui_init(void)
140 Evas_Object *lay, *obj;
142 /* dialer should never, ever quit */
143 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE);
145 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
146 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
147 elm_app_info_set(gui_init, "ofono-efl", "themes/default.edj");
149 snprintf(def_theme, sizeof(def_theme), "%s/themes/default.edj",
150 elm_app_data_dir_get());
152 elm_theme_extension_add(NULL, def_theme);
153 elm_theme_overlay_add(NULL, def_theme);
155 win = elm_win_util_standard_add("ofono-dialer", "oFono Dialer");
156 EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
157 elm_win_autodel_set(win, EINA_FALSE);
159 flip = elm_flip_add(win);
160 evas_object_size_hint_weight_set(flip,
161 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
162 evas_object_size_hint_align_set(flip, EVAS_HINT_FILL, EVAS_HINT_FILL);
163 elm_win_resize_object_add(win, flip);
164 evas_object_smart_callback_add(flip, "animate,done",
165 _gui_call_sync, NULL);
166 evas_object_show(flip);
168 main_layout = lay = gui_layout_add(win, "main");
169 EINA_SAFETY_ON_NULL_RETURN_VAL(lay, EINA_FALSE);
170 evas_object_size_hint_weight_set(lay,
171 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
172 evas_object_size_hint_align_set(lay, EVAS_HINT_FILL, EVAS_HINT_FILL);
173 elm_object_part_content_set(flip, "front", lay);
174 evas_object_show(lay);
176 elm_object_signal_callback_add(lay, "clicked,*", "gui",
179 keypad = obj = keypad_add(win);
180 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
181 elm_object_part_content_set(lay, "elm.swallow.keypad", obj);
183 contacts = obj = contacts_add(win);
184 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
185 elm_object_part_content_set(lay, "elm.swallow.contacts", obj);
187 history = obj = history_add(win);
188 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
189 elm_object_part_content_set(lay, "elm.swallow.history", obj);
193 cs = obj = callscreen_add(win);
194 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
195 evas_object_size_hint_weight_set(obj,
196 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
197 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
198 elm_object_part_content_set(flip, "back", obj);
199 evas_object_show(obj);
201 /* TODO: make it match better with Tizen: icon and other properties */
202 evas_object_resize(win, 720, 1280);
204 /* do not show it yet, RC will check if it should be visible or not */
208 void gui_shutdown(void)