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_activecall_set(Evas_Object *o)
87 elm_object_part_content_set(main_layout,
88 "elm.swallow.activecall", o);
89 elm_object_signal_emit(main_layout, "show,activecall", "gui");
91 o = elm_object_part_content_unset(
92 main_layout, "elm.swallow.activecall");
93 elm_object_signal_emit(main_layout, "hide,activecall", "gui");
98 void gui_call_enter(void)
106 in_flip_anim = EINA_TRUE;
107 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
108 elm_object_focus_set(cs, EINA_TRUE);
111 void gui_call_exit(void)
115 in_call = EINA_FALSE;
118 in_flip_anim = EINA_TRUE;
119 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
120 elm_object_focus_set(cs, EINA_FALSE);
123 static void _gui_call_sync(void *data __UNUSED__, Evas_Object *o __UNUSED__,
124 void *event_info __UNUSED__)
126 Eina_Bool showing_call = !elm_flip_front_visible_get(flip);
128 if (showing_call ^ in_call) {
129 DBG("Flip back to sync");
130 elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS);
131 elm_object_focus_set(cs, in_call);
133 in_flip_anim = EINA_FALSE;
136 static void _on_clicked(void *data __UNUSED__, Evas_Object *o __UNUSED__,
137 const char *emission, const char *source __UNUSED__)
139 DBG("signal: %s", emission);
141 EINA_SAFETY_ON_FALSE_RETURN(eina_str_has_prefix(emission, "clicked,"));
142 emission += strlen("clicked,");
144 if (strcmp(emission, "keypad") == 0)
146 else if (strcmp(emission, "contacts") == 0)
148 else if (strcmp(emission, "history") == 0)
152 Eina_Bool gui_init(const char *theme)
154 Evas_Object *lay, *obj;
157 /* dialer should never, ever quit */
158 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE);
160 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
161 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
162 elm_app_info_set(gui_init, "ofono-efl", "themes/default.edj");
164 snprintf(def_theme, sizeof(def_theme), "%s/themes/default.edj",
165 elm_app_data_dir_get());
167 elm_theme_extension_add(NULL, def_theme);
169 elm_theme_overlay_add(NULL, def_theme);
172 if (theme[0] != '/') {
173 if (eina_str_has_suffix(theme, ".edj")) {
174 snprintf(tmp, sizeof(tmp), "%s/themes/%s",
175 elm_app_data_dir_get(), theme);
177 snprintf(tmp, sizeof(tmp), "%s/themes/%s.edj",
178 elm_app_data_dir_get(), theme);
182 elm_theme_overlay_add(NULL, theme);
185 win = elm_win_util_standard_add("ofono-dialer", "oFono Dialer");
186 EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
187 elm_win_autodel_set(win, EINA_FALSE);
189 flip = elm_flip_add(win);
190 evas_object_size_hint_weight_set(flip,
191 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
192 evas_object_size_hint_align_set(flip, EVAS_HINT_FILL, EVAS_HINT_FILL);
193 elm_win_resize_object_add(win, flip);
194 evas_object_smart_callback_add(flip, "animate,done",
195 _gui_call_sync, NULL);
196 evas_object_show(flip);
198 main_layout = lay = gui_layout_add(win, "main");
199 EINA_SAFETY_ON_NULL_RETURN_VAL(lay, EINA_FALSE);
200 evas_object_size_hint_weight_set(lay,
201 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
202 evas_object_size_hint_align_set(lay, EVAS_HINT_FILL, EVAS_HINT_FILL);
203 elm_object_part_content_set(flip, "front", lay);
204 evas_object_show(lay);
206 elm_object_signal_callback_add(lay, "clicked,*", "gui",
209 keypad = obj = keypad_add(win);
210 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
211 elm_object_part_content_set(lay, "elm.swallow.keypad", obj);
213 contacts = obj = contacts_add(win);
214 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
215 elm_object_part_content_set(lay, "elm.swallow.contacts", obj);
217 history = obj = history_add(win);
218 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
219 elm_object_part_content_set(lay, "elm.swallow.history", obj);
223 cs = obj = callscreen_add(win);
224 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
225 evas_object_size_hint_weight_set(obj,
226 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
227 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
228 elm_object_part_content_set(flip, "back", obj);
229 evas_object_show(obj);
231 /* TODO: make it match better with Tizen: icon and other properties */
232 obj = elm_layout_edje_get(lay);
233 edje_object_size_min_get(obj, &w, &h);
234 if ((w == 0) || (h == 0))
235 edje_object_size_min_restricted_calc(obj, &w, &h, w, h);
236 if ((w == 0) || (h == 0))
237 edje_object_parts_extends_calc(obj, NULL, NULL, &w, &h);
238 evas_object_resize(win, w, h);
240 /* do not show it yet, RC will check if it should be visible or not */
244 void gui_shutdown(void)