|
|
|
@ -3,23 +3,12 @@ |
|
|
|
|
*/ |
|
|
|
|
#include "e.h" |
|
|
|
|
|
|
|
|
|
struct _E_Dialog_Button |
|
|
|
|
{ |
|
|
|
|
E_Dialog *dialog; |
|
|
|
|
Evas_Object *obj, *obj_icon; |
|
|
|
|
char *label; |
|
|
|
|
char *icon; |
|
|
|
|
void (*func) (void *data, E_Dialog *dia); |
|
|
|
|
void *data; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/* local subsystem functions */ |
|
|
|
|
static void _e_dialog_free(E_Dialog *dia); |
|
|
|
|
static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source); |
|
|
|
|
static void _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event); |
|
|
|
|
static void _e_dialog_del_func_cb(void *data, E_Dialog *dia); |
|
|
|
|
static void _e_dialog_cb_delete(E_Win *win); |
|
|
|
|
static void _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event); |
|
|
|
|
|
|
|
|
|
static void _e_dialog_cb_wid_on_focus(void *data, Evas_Object *obj); |
|
|
|
|
|
|
|
|
|
/* local subsystem globals */ |
|
|
|
|
|
|
|
|
@ -59,14 +48,11 @@ e_dialog_new(E_Container *con) |
|
|
|
|
"widgets/dialog/main"); |
|
|
|
|
evas_object_move(o, 0, 0); |
|
|
|
|
evas_object_show(o); |
|
|
|
|
|
|
|
|
|
o = e_box_add(e_win_evas_get(dia->win)); |
|
|
|
|
|
|
|
|
|
o = e_widget_list_add(e_win_evas_get(dia->win), 1, 1); |
|
|
|
|
e_widget_on_focus_hook_set(o, _e_dialog_cb_wid_on_focus, dia); |
|
|
|
|
dia->box_object = o; |
|
|
|
|
e_box_orientation_set(o, 1); |
|
|
|
|
e_box_homogenous_set(o, 1); |
|
|
|
|
e_box_align_set(o, 0.5, 0.5); |
|
|
|
|
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o); |
|
|
|
|
evas_object_show(o); |
|
|
|
|
|
|
|
|
|
o = evas_object_rectangle_add(e_win_evas_get(dia->win)); |
|
|
|
|
dia->event_object = o; |
|
|
|
@ -83,109 +69,27 @@ e_dialog_new(E_Container *con) |
|
|
|
|
|
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_dialog_cb_key_down, dia); |
|
|
|
|
|
|
|
|
|
dia->focused = NULL; |
|
|
|
|
|
|
|
|
|
return dia; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
Evas_Coord mw, mh; |
|
|
|
|
|
|
|
|
|
db = E_NEW(E_Dialog_Button, 1); |
|
|
|
|
db->dialog = dia; |
|
|
|
|
if (label) db->label = strdup(label); |
|
|
|
|
if (icon) db->icon = strdup(icon); |
|
|
|
|
db->func = func; |
|
|
|
|
db->data = data; |
|
|
|
|
db->obj = edje_object_add(e_win_evas_get(dia->win)); |
|
|
|
|
e_theme_edje_object_set(db->obj, "base/theme/dialog", |
|
|
|
|
"widgets/dialog/button"); |
|
|
|
|
edje_object_signal_callback_add(db->obj, "click", "", |
|
|
|
|
_e_dialog_cb_button_clicked, db); |
|
|
|
|
edje_object_part_text_set(db->obj, "button_text", db->label); |
|
|
|
|
|
|
|
|
|
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_DOWN, _e_dialog_button_cb_mouse_down, db); |
|
|
|
|
|
|
|
|
|
if (icon) |
|
|
|
|
{ |
|
|
|
|
db->obj_icon = edje_object_add(e_win_evas_get(dia->win)); |
|
|
|
|
e_util_edje_icon_set(db->obj_icon, icon); |
|
|
|
|
edje_object_part_swallow(db->obj, "icon_swallow", db->obj_icon); |
|
|
|
|
edje_object_signal_emit(db->obj, "icon_visible", ""); |
|
|
|
|
edje_object_message_signal_process(db->obj); |
|
|
|
|
evas_object_show(db->obj_icon); |
|
|
|
|
} |
|
|
|
|
edje_object_size_min_calc(db->obj, &mw, &mh); |
|
|
|
|
e_box_pack_end(dia->box_object, db->obj); |
|
|
|
|
e_box_pack_options_set(db->obj, |
|
|
|
|
1, 1, /* fill */ |
|
|
|
|
0, 1, /* expand */ |
|
|
|
|
0.5, 0.5, /* align */ |
|
|
|
|
mw, mh, /* min */ |
|
|
|
|
9999, mh /* max */ |
|
|
|
|
); |
|
|
|
|
evas_object_show(db->obj); |
|
|
|
|
|
|
|
|
|
dia->buttons = evas_list_append(dia->buttons, db); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
e_dialog_button_focus_num(E_Dialog *dia, int button) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db = NULL; |
|
|
|
|
|
|
|
|
|
if (button < 0) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
db = evas_list_nth(dia->buttons, button); |
|
|
|
|
|
|
|
|
|
if (!db)
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
if (dia->focused) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *focused; |
|
|
|
|
|
|
|
|
|
focused = dia->focused->data; |
|
|
|
|
if (focused) |
|
|
|
|
edje_object_signal_emit(focused->obj, "unfocus", "");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dia->focused = evas_list_nth_list(dia->buttons, button); |
|
|
|
|
edje_object_signal_emit(db->obj, "focus", ""); |
|
|
|
|
Evas_Object *o; |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
if (!func) func = _e_dialog_del_func_cb; |
|
|
|
|
o = e_widget_button_add(e_win_evas_get(dia->win), label, icon, func, data, dia); |
|
|
|
|
e_widget_list_object_append(dia->box_object, o, 1, 1, 0.5); |
|
|
|
|
dia->buttons = evas_list_append(dia->buttons, o); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button) |
|
|
|
|
e_dialog_button_focus_num(E_Dialog *dia, int button) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db = NULL; |
|
|
|
|
|
|
|
|
|
if (!button) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
db = evas_list_find(dia->buttons, button); |
|
|
|
|
|
|
|
|
|
if (!db) |
|
|
|
|
return 0; |
|
|
|
|
Evas_Object *o; |
|
|
|
|
|
|
|
|
|
if (dia->focused) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *focused; |
|
|
|
|
|
|
|
|
|
focused = dia->focused->data; |
|
|
|
|
if (focused) |
|
|
|
|
edje_object_signal_emit(focused->obj, "unfocus", "");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dia->focused = evas_list_find_list(dia->buttons, button); |
|
|
|
|
edje_object_signal_emit(db->obj, "focus", ""); |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
o = evas_list_nth(dia->buttons, button); |
|
|
|
|
if (o) e_widget_focus_steal(o); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
@ -226,6 +130,8 @@ e_dialog_icon_set(E_Dialog *dia, char *icon, Evas_Coord size) |
|
|
|
|
void |
|
|
|
|
e_dialog_content_set(E_Dialog *dia, Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) |
|
|
|
|
{ |
|
|
|
|
dia->content_object = obj; |
|
|
|
|
e_widget_on_focus_hook_set(obj, _e_dialog_cb_wid_on_focus, dia); |
|
|
|
|
edje_extern_object_min_size_set(obj, minw, minh); |
|
|
|
|
edje_object_part_swallow(dia->bg_object, "content_swallow", obj); |
|
|
|
|
evas_object_show(obj); |
|
|
|
@ -246,7 +152,7 @@ e_dialog_show(E_Dialog *dia) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
o = dia->box_object; |
|
|
|
|
e_box_min_size_get(o, &mw, &mh); |
|
|
|
|
e_widget_min_size_get(o, &mw, &mh); |
|
|
|
|
edje_extern_object_min_size_set(o, mw, mh); |
|
|
|
|
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o); |
|
|
|
|
|
|
|
|
@ -256,58 +162,30 @@ e_dialog_show(E_Dialog *dia) |
|
|
|
|
e_win_size_min_set(dia->win, mw, mh); |
|
|
|
|
e_win_size_max_set(dia->win, mw, mh); |
|
|
|
|
e_win_show(dia->win); |
|
|
|
|
|
|
|
|
|
if (!e_widget_focus_get(dia->box_object)) |
|
|
|
|
e_widget_focus_set(dia->box_object, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* local subsystem functions */ |
|
|
|
|
static void |
|
|
|
|
_e_dialog_free(E_Dialog *dia) |
|
|
|
|
{ |
|
|
|
|
while (dia->buttons) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
|
|
|
|
|
db = dia->buttons->data; |
|
|
|
|
dia->buttons = evas_list_remove_list(dia->buttons, dia->buttons); |
|
|
|
|
E_FREE(db->label); |
|
|
|
|
E_FREE(db->icon); |
|
|
|
|
evas_object_del(db->obj); |
|
|
|
|
if (db->obj_icon) evas_object_del(db->obj_icon); |
|
|
|
|
free(db); |
|
|
|
|
} |
|
|
|
|
if (dia->buttons) evas_list_free(dia->buttons); |
|
|
|
|
if (dia->text_object) evas_object_del(dia->text_object); |
|
|
|
|
if (dia->icon_object) evas_object_del(dia->icon_object); |
|
|
|
|
if (dia->box_object) evas_object_del(dia->box_object); |
|
|
|
|
if (dia->bg_object) evas_object_del(dia->bg_object); |
|
|
|
|
if (dia->content_object) evas_object_del(dia->content_object); |
|
|
|
|
if (dia->event_object) evas_object_del(dia->event_object); |
|
|
|
|
e_object_del(E_OBJECT(dia->win)); |
|
|
|
|
free(dia); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) |
|
|
|
|
_e_dialog_del_func_cb(void *data, E_Dialog *dia) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
|
|
|
|
|
db = data; |
|
|
|
|
if (db->func)
|
|
|
|
|
{ |
|
|
|
|
edje_object_signal_emit(db->obj, "focus", ""); |
|
|
|
|
db->func(db->data, db->dialog); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
e_object_del(E_OBJECT(db->dialog)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event) |
|
|
|
|
{
|
|
|
|
|
E_Dialog *dia; |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
|
|
|
|
|
db = data; |
|
|
|
|
dia = db->dialog; |
|
|
|
|
|
|
|
|
|
e_dialog_button_focus_button(dia, db); |
|
|
|
|
e_object_del(E_OBJECT(dia)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -318,52 +196,64 @@ _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event) |
|
|
|
|
|
|
|
|
|
ev = event; |
|
|
|
|
dia = data; |
|
|
|
|
|
|
|
|
|
if (!strcmp(ev->keyname, "Tab")) |
|
|
|
|
{ |
|
|
|
|
if ((dia->focused) && (dia->buttons)) |
|
|
|
|
if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(dia->win)), "Shift")) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db, *ndb; |
|
|
|
|
|
|
|
|
|
db = dia->focused->data;
|
|
|
|
|
if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(dia->win)), "Shift")) |
|
|
|
|
if (e_widget_focus_get(dia->box_object)) |
|
|
|
|
{ |
|
|
|
|
if (dia->focused->prev) dia->focused = dia->focused->prev; |
|
|
|
|
else dia->focused = evas_list_last(dia->buttons); |
|
|
|
|
if (!e_widget_focus_jump(dia->box_object, 0)) |
|
|
|
|
{ |
|
|
|
|
if (dia->text_object) |
|
|
|
|
e_widget_focus_set(dia->box_object, 0); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
e_widget_focus_set(dia->content_object, 0); |
|
|
|
|
if (!e_widget_focus_get(dia->content_object)) |
|
|
|
|
e_widget_focus_set(dia->box_object, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (dia->focused->next) dia->focused = dia->focused->next; |
|
|
|
|
else dia->focused = dia->buttons;
|
|
|
|
|
} |
|
|
|
|
ndb = dia->focused->data; |
|
|
|
|
if (ndb != db) |
|
|
|
|
{ |
|
|
|
|
edje_object_signal_emit(db->obj, "unfocus", ""); |
|
|
|
|
edje_object_signal_emit(ndb->obj, "focus", ""); |
|
|
|
|
edje_object_signal_emit(ndb->obj, "enter", ""); |
|
|
|
|
if (!e_widget_focus_jump(dia->content_object, 0)) |
|
|
|
|
e_widget_focus_set(dia->box_object, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
|
|
|
|
|
dia->focused = dia->buttons; |
|
|
|
|
|
|
|
|
|
db = dia->focused->data; |
|
|
|
|
edje_object_signal_emit(db->obj, "focus", ""); |
|
|
|
|
edje_object_signal_emit(db->obj, "enter", "");
|
|
|
|
|
if (e_widget_focus_get(dia->box_object)) |
|
|
|
|
{ |
|
|
|
|
if (!e_widget_focus_jump(dia->box_object, 1)) |
|
|
|
|
{ |
|
|
|
|
if (dia->text_object) |
|
|
|
|
e_widget_focus_set(dia->box_object, 1); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
e_widget_focus_set(dia->content_object, 1); |
|
|
|
|
if (!e_widget_focus_get(dia->content_object)) |
|
|
|
|
e_widget_focus_set(dia->box_object, 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (!e_widget_focus_jump(dia->content_object, 1)) |
|
|
|
|
e_widget_focus_set(dia->box_object, 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (((!strcmp(ev->keyname, "Return")) ||
|
|
|
|
|
(!strcmp(ev->keyname, "KP_Enter")) ||
|
|
|
|
|
(!strcmp(ev->keyname, "space"))) && dia->focused) |
|
|
|
|
(!strcmp(ev->keyname, "space")))) |
|
|
|
|
{ |
|
|
|
|
E_Dialog_Button *db; |
|
|
|
|
|
|
|
|
|
db = evas_list_data(dia->focused); |
|
|
|
|
edje_object_signal_emit(db->obj, "click", "");
|
|
|
|
|
Evas_Object *o = NULL; |
|
|
|
|
|
|
|
|
|
if ((dia->content_object) && (e_widget_focus_get(dia->content_object))) |
|
|
|
|
o = e_widget_focused_object_get(dia->content_object); |
|
|
|
|
else |
|
|
|
|
o = e_widget_focused_object_get(dia->box_object); |
|
|
|
|
if (o) e_widget_activate(o); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -375,3 +265,16 @@ _e_dialog_cb_delete(E_Win *win) |
|
|
|
|
dia = win->data; |
|
|
|
|
e_object_del(E_OBJECT(dia)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_e_dialog_cb_wid_on_focus(void *data, Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
E_Dialog *dia; |
|
|
|
|
|
|
|
|
|
dia = data; |
|
|
|
|
if (obj == dia->content_object) |
|
|
|
|
e_widget_focused_object_clear(dia->box_object); |
|
|
|
|
else if (dia->content_object) |
|
|
|
|
e_widget_focused_object_clear(dia->content_object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|