Add ability to focus a button in an E_Dialog by either its number or a
pointer to it. When we click a button we need to send a focus signal to it. SVN revision: 16940
This commit is contained in:
parent
e9e7bfd9ec
commit
d4ebde128e
|
@ -1131,7 +1131,7 @@ ACT_FN_GO(exit)
|
||||||
e_dialog_icon_set(dia, "enlightenment/exit", 64);
|
e_dialog_icon_set(dia, "enlightenment/exit", 64);
|
||||||
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok, NULL);
|
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok, NULL);
|
||||||
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
|
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
|
||||||
e_dialog_button_focus(dia, 1);
|
e_dialog_button_focus_num(dia, 1);
|
||||||
e_win_centered_set(dia->win, 1);
|
e_win_centered_set(dia->win, 1);
|
||||||
e_dialog_show(dia);
|
e_dialog_show(dia);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct _E_Dialog_Button
|
||||||
static void _e_dialog_free(E_Dialog *dia);
|
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_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
static void _e_dialog_button_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event);
|
static void _e_dialog_button_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event);
|
||||||
|
static void _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
||||||
static void _e_dialog_cb_delete(E_Win *win);
|
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_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
||||||
|
|
||||||
|
@ -115,6 +116,7 @@ e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *
|
||||||
edje_object_part_text_set(db->obj, "button_text", db->label);
|
edje_object_part_text_set(db->obj, "button_text", db->label);
|
||||||
|
|
||||||
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_IN, _e_dialog_button_cb_mouse_in, dia);
|
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_IN, _e_dialog_button_cb_mouse_in, dia);
|
||||||
|
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_DOWN, _e_dialog_button_cb_mouse_down, db);
|
||||||
|
|
||||||
if (icon)
|
if (icon)
|
||||||
{
|
{
|
||||||
|
@ -141,13 +143,17 @@ e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
e_dialog_button_focus(E_Dialog *dia, int button)
|
e_dialog_button_focus_num(E_Dialog *dia, int button)
|
||||||
{
|
{
|
||||||
E_Dialog_Button *db = NULL;
|
E_Dialog_Button *db = NULL;
|
||||||
|
|
||||||
|
if (button < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
db = evas_list_nth(dia->buttons, button);
|
db = evas_list_nth(dia->buttons, button);
|
||||||
|
|
||||||
if (!db) return 0;
|
if (!db)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (dia->focused)
|
if (dia->focused)
|
||||||
{
|
{
|
||||||
|
@ -164,6 +170,34 @@ e_dialog_button_focus(E_Dialog *dia, int button)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button)
|
||||||
|
{
|
||||||
|
E_Dialog_Button *db = NULL;
|
||||||
|
|
||||||
|
if (!button)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
db = evas_list_find(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_find_list(dia->buttons, button);
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_dialog_title_set(E_Dialog *dia, char *title)
|
e_dialog_title_set(E_Dialog *dia, char *title)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +279,10 @@ _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission,
|
||||||
|
|
||||||
db = data;
|
db = data;
|
||||||
if (db->func)
|
if (db->func)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
db->func(db->data, db->dialog);
|
db->func(db->data, db->dialog);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
e_object_del(E_OBJECT(db->dialog));
|
e_object_del(E_OBJECT(db->dialog));
|
||||||
}
|
}
|
||||||
|
@ -256,6 +293,18 @@ _e_dialog_button_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||||
edje_object_signal_emit(obj, "enter", "");
|
edje_object_signal_emit(obj, "enter", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Implement shift-tab and left arrow */
|
/* TODO: Implement shift-tab and left arrow */
|
||||||
static void
|
static void
|
||||||
_e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
_e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||||
|
|
|
@ -125,7 +125,6 @@ static void _e_entry_smart_del(Evas_Object *object)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_entry_smart_raise(Evas_Object *object)
|
static void _e_entry_smart_raise(Evas_Object *object)
|
||||||
|
@ -134,6 +133,8 @@ static void _e_entry_smart_raise(Evas_Object *object)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evas_object_raise(e_entry_sd->edje_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_entry_smart_lower(Evas_Object *object)
|
static void _e_entry_smart_lower(Evas_Object *object)
|
||||||
|
@ -142,6 +143,8 @@ static void _e_entry_smart_lower(Evas_Object *object)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evas_object_lower(e_entry_sd->edje_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_entry_smart_stack_above(Evas_Object *object, Evas_Object *above)
|
static void _e_entry_smart_stack_above(Evas_Object *object, Evas_Object *above)
|
||||||
|
@ -150,6 +153,8 @@ static void _e_entry_smart_stack_above(Evas_Object *object, Evas_Object *above)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evas_object_stack_above(e_entry_sd->edje_object, above);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_entry_smart_stack_below(Evas_Object *object, Evas_Object *below)
|
static void _e_entry_smart_stack_below(Evas_Object *object, Evas_Object *below)
|
||||||
|
@ -158,6 +163,8 @@ static void _e_entry_smart_stack_below(Evas_Object *object, Evas_Object *below)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evas_object_stack_below(e_entry_sd->edje_object, below);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_entry_smart_move(Evas_Object *object, Evas_Coord x, Evas_Coord y)
|
static void _e_entry_smart_move(Evas_Object *object, Evas_Coord x, Evas_Coord y)
|
||||||
|
@ -196,6 +203,8 @@ static void _e_entry_smart_hide(Evas_Object *object)
|
||||||
|
|
||||||
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evas_object_hide (e_entry_sd->edje_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when the user presses a key */
|
/* Called when the user presses a key */
|
||||||
|
@ -226,9 +235,6 @@ _e_entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||||
e_editable_text_insert(obj, key_event->string);
|
e_editable_text_insert(obj, key_event->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Evas_Object *e_editable_text_add(Evas *evas)
|
Evas_Object *e_editable_text_add(Evas *evas)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
|
Loading…
Reference in New Issue